From 4e679d1645d0ed34abed550264b75eed75bf3190 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Wed, 9 Apr 2025 10:52:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B8=AD=E7=9A=84=E4=BB=A3=E7=A0=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=92=8C=E7=B1=BB=E5=9E=8B=E5=A3=B0=E6=98=8E=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E4=BB=A3=E7=A0=81=E4=B8=80=E8=87=B4=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/CarCheck.ets | 26 +- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/pages/UserInfo.ets | 4 +- .../ets/pages/compontents/errorMsgDialog.ets | 305 +++++++++--------- .../judge/BoardPrePareSetPopup.ets | 2 +- entry/src/main/ets/pages/judgeSDK/judge.ets | 300 +++++++++-------- .../judgeSDK/utils/voiceAnnouncements.ets | 34 +- 7 files changed, 342 insertions(+), 331 deletions(-) diff --git a/entry/src/main/ets/pages/CarCheck.ets b/entry/src/main/ets/pages/CarCheck.ets index d1602a6c..bd87e65e 100644 --- a/entry/src/main/ets/pages/CarCheck.ets +++ b/entry/src/main/ets/pages/CarCheck.ets @@ -4,7 +4,7 @@ import TopLogo from './compontents/TopLogo'; import testNapi from '@ohos.hiserialsdk'; import { DwMapData, PassData, RealNumData, StackValueData, WarnFlagData, WarnFlagTipData } from '../mock'; import { BaseInfoType, RouteParamsType } from '../model/Common'; -import { CarCheckDataType, CarConfigurationParams, CarInfoType, SpzdType } from '../model'; +import { CarCheckDataType, CarConfigurationParams, CarInfoType } from '../model'; import { BusinessError } from '@ohos.base'; import { voiceService } from '../utils/Voice'; import dayTs from '../utils/Date'; @@ -144,7 +144,7 @@ struct Index { const param: CarConfigurationParams = { body: { "carIdString": this.carInfo.carId || "", //考车ID - "deviceNo": baseInfo.deviceNo || "" + "deviceNo": baseInfo?.deviceNo || "" } } @@ -221,8 +221,7 @@ struct Index { } return } - - if (this.warnFlagTip.get(that.index).length > 1) { + if ((this.warnFlagTip.get(that.index) || []).length > 1) { if (that.stachValue[that.index] != that.signArr[that.realNum[that.index]]) { that.warnFlag[that.index] = '2' } @@ -327,9 +326,10 @@ struct Index { // if (!flag) { // that.warnFlag[index] = '2'; // } - const spzd: SpzdType = AppStorage.get('spzd')!; - const hasTruthyValue = Object.values(spzd).some((value: string) => value); - that.warnFlag[index] = hasTruthyValue ? '1' : '2'; + // TODO 视频遮挡 + // const spzd: SpzdType = AppStorage.get('spzd')!; + // const hasTruthyValue = Object.values(spzd).some((value: string) => value); + // that.warnFlag[index] = hasTruthyValue ? '1' : '2'; } else { that.warnFlag[index] = '2' } @@ -346,16 +346,16 @@ struct Index { this.passArray[this.index] = true this.passArray = JSON.parse(JSON.stringify(this.passArray)) this.subFlag = true - let name: string = this.warnFlagTip.get(this.index)[0] - if (this.warnFlagTip.get(this.index).length == 1) { - this.vocObj.playAudio({ + let name: string = this.warnFlagTip.get(this.index)?.[0] || ''; + if (this.warnFlagTip.get(this.index)?.length == 1) { + this.vocObj!.playAudio({ type: 1, name, }) - } else if (this.warnFlagTip.get(this.index).length == 2) { + } else if (this.warnFlagTip.get(this.index)?.length == 2) { if (this.signArr[this.realNum[this.index]] && this.signArr[this.realNum[this.index]] != '0') { - name = this.warnFlagTip.get(this.index)[1] - this.vocObj.playAudio({ + name = this.warnFlagTip.get(this.index)?.[1] || ''; + this.vocObj!.playAudio({ type: 1, name, }) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 8858543e..95ed1b7a 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -64,7 +64,7 @@ struct Index { private context = getContext(this) as common.UIAbilityContext; async aboutToAppear() { - this.avPlayer = new VoiceAnnounce(); + this.avPlayer = new VoiceAnnounce(this.context); this.ratio = AppStorage.get('ratio') this.initParamFlag = false this.delLoading = false diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 75320021..91123cb9 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -15,7 +15,6 @@ import LoadingPopup from './compontents/judge/LoadingPopup'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import { JudgeConfig } from './judgeSDK/utils/judgeConfig'; // import { initJudgeUdp } from '../common/utils/UdpJudge'; -import errorMsgDialog from './compontents/errorMsgDialog'; import imageBtn from './compontents/imageBtn'; import { CryptoJS } from '@ohos/crypto-js'; @@ -45,6 +44,7 @@ import { GetCurrentTime, NumberToByteArray } from '../utils/Common'; import DB from '../utils/DbSql'; import { CenterUDPClientInstance } from '../utils/business/CenterUdpBusiness'; import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; +import errorMsgDialog from './compontents/errorMsgDialog'; @Entry @Component @@ -210,7 +210,7 @@ struct UserInfo { ] aboutToAppear() { - this.avPlayer = new VoiceAnnounce(); + this.avPlayer = new VoiceAnnounce(this.context); } async onPageShow() { diff --git a/entry/src/main/ets/pages/compontents/errorMsgDialog.ets b/entry/src/main/ets/pages/compontents/errorMsgDialog.ets index e06c1319..d5f61fbe 100644 --- a/entry/src/main/ets/pages/compontents/errorMsgDialog.ets +++ b/entry/src/main/ets/pages/compontents/errorMsgDialog.ets @@ -1,156 +1,173 @@ -import router from '@ohos.router'; +// import router from '@ohos.router'; @CustomDialog export default struct errorMsgDialog { + dialogRatio: number = 0.8 + title?: string + type: string //1 tip 2loading 3Dialog + @State angle: number = 0 private controller?: CustomDialogController cancel: () => void = () => { } confirm: () => void = () => { } - 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) - .backgroundImage($r('app.media.button_nor')) - .backgroundImageSize({ width: '100%', height: '100%' }) - // .margin({ bottom: 12 * this.ratio }) - } build() { - Column() { - if (this.title) { - Text(this.title) - .fontSize(30 * this.dialogRatio) - .margin(120 * this.dialogRatio) - } - if (this.type == '2') { - Image($r('app.media.open_loading')) - .width(200) - .rotate({ angle: this.angle }) - .height(200) - .animation({ - duration: 5000, // 动画时长 - curve: Curve.EaseOut, // 动画曲线 - delay: 500, // 动画延迟 - iterations: -1, // 播放次数 - playMode: PlayMode.Normal, // 动画模式 - }) - .margin(50) - } - if (this.type == '3') { - Row() { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(' 取 消 ') - .fontSize(24 * globalThis.ratio * this.dialogRatio * 0.6) - .fontColor('#fff') - .width(60 * globalThis.ratio * this.dialogRatio) - } - .commStyle() - .onClick(() => { - if (this.controller != undefined) { - const errorCode = AppStorage.Get('errorMsg'); - // const errorCodeFlage=AppStorage.Get('errorCodeFlage'); - // console.log('errorCode',errorCode,errorCodeFlage) - if (errorCode == 0) { - router.replaceUrl({ - url: 'pages/Index', - }, router.RouterMode.Single); - router.clear(); - - } - this.cancel() - this.controller.close() - } - }).margin({ right: 10 * globalThis.ratio * this.dialogRatio }) - - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(' 确 定 ') - .fontSize(24 * globalThis.ratio * this.dialogRatio * 0.6) - .fontColor('#fff') - .width(60 * globalThis.ratio * this.dialogRatio) - } - .commStyle() - .onClick(() => { - const errorCode = AppStorage.Get('errorCode'); - 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 }) - } - if (this.type == '4') { - Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - Text(' 确 定 ') - .fontSize(24 * globalThis.ratio * this.dialogRatio * 0.6) - .fontColor('#fff') - .width(60 * globalThis.ratio * this.dialogRatio) - } - .commStyle() - .onClick(() => { - const errorCode = AppStorage.Get('errorCode'); - 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() - } - } - ) - } - } - .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 +// +// @CustomDialog +// export default struct errorMsgDialog { +// private controller?: CustomDialogController +// cancel: () => void = () => { +// } +// confirm: () => void = () => { +// } +// 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) +// .backgroundImage($r('app.media.button_nor')) +// .backgroundImageSize({ width: '100%', height: '100%' }) +// // .margin({ bottom: 12 * this.ratio }) +// } +// +// build() { +// Column() { +// if (this.title) { +// Text(this.title) +// .fontSize(30 * this.dialogRatio) +// .margin(120 * this.dialogRatio) +// } +// if (this.type == '2') { +// Image($r('app.media.open_loading')) +// .width(200) +// .rotate({ angle: this.angle }) +// .height(200) +// .animation({ +// duration: 5000, // 动画时长 +// curve: Curve.EaseOut, // 动画曲线 +// delay: 500, // 动画延迟 +// iterations: -1, // 播放次数 +// playMode: PlayMode.Normal, // 动画模式 +// }) +// .margin(50) +// } +// if (this.type == '3') { +// Row() { +// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { +// Text(' 取 消 ') +// .fontSize(24 * globalThis.ratio * this.dialogRatio * 0.6) +// .fontColor('#fff') +// .width(60 * globalThis.ratio * this.dialogRatio) +// } +// .commStyle() +// .onClick(() => { +// if (this.controller != undefined) { +// const errorCode = AppStorage.Get('errorMsg'); +// // const errorCodeFlage=AppStorage.Get('errorCodeFlage'); +// // console.log('errorCode',errorCode,errorCodeFlage) +// if (errorCode == 0) { +// router.replaceUrl({ +// url: 'pages/Index', +// }, router.RouterMode.Single); +// router.clear(); +// +// } +// this.cancel() +// this.controller.close() +// } +// }).margin({ right: 10 * globalThis.ratio * this.dialogRatio }) +// +// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { +// Text(' 确 定 ') +// .fontSize(24 * globalThis.ratio * this.dialogRatio * 0.6) +// .fontColor('#fff') +// .width(60 * globalThis.ratio * this.dialogRatio) +// } +// .commStyle() +// .onClick(() => { +// const errorCode = AppStorage.Get('errorCode'); +// 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 }) +// } +// if (this.type == '4') { +// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { +// Text(' 确 定 ') +// .fontSize(24 * globalThis.ratio * this.dialogRatio * 0.6) +// .fontColor('#fff') +// .width(60 * globalThis.ratio * this.dialogRatio) +// } +// .commStyle() +// .onClick(() => { +// const errorCode = AppStorage.Get('errorCode'); +// 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() +// } +// } +// ) +// } +// } +// .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 diff --git a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets index 479054f7..32bc48ed 100644 --- a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets +++ b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets @@ -83,7 +83,7 @@ export default struct DeductedPopup { async aboutToAppear() { this.carInfo = AppStorage.get('carInfo') this.singlePlay = AppStorage.get('singlePlay') - this.avPlayer = new VoiceAnnounce(); + this.avPlayer = new VoiceAnnounce(this.context); this.judgeTask = new JudgeTask(); const mediaTest = new FilePhoto(this.context); this.filePhoto = mediaTest diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index dc75b64f..e412b03f 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -13,13 +13,7 @@ import { JudgeConfig } from './utils/judgeConfig'; import { LANE } from '../judgeSDK/api/judgeSDK.d'; import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; -import { - getCarStatus, - getCenterProjectStatus, - plcStrToJson, - plcStrToWXJson, - promptWxCode -} from './utils/judgeCommon'; +import { getCarStatus, getCenterProjectStatus, plcStrToJson, plcStrToWXJson, promptWxCode } from './utils/judgeCommon'; import { examCalcGpsDistance, @@ -53,6 +47,7 @@ import { JudgeBeginObj, JudgeCallBackData, JudgeConfigObj, + JudgeConfigObjKmItems, JudgeEventKf, JudgeInitObj, JudgeKFXM, @@ -64,7 +59,6 @@ import { JudgeXMJS, Km3JudgeInitConfig, KmItem, - JudgeConfigObjKmItems, MarkRule, Plc, ProjectInfo, @@ -185,38 +179,6 @@ export default class Judge { private isExamEnd: boolean // 是否发送udp private isUdpEnd: boolean = false - // 处理udp plc信号 - handleUdp = async (msg: string) => { - console.info('plc信号', msg) - const stachArr = msg.split(',') - if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { - return - } - const plcData = await this.getPlcData(msg); - // 4.过程数据 - await this.fileLog.setExamJudgeData(JSON.stringify(plcData)) - //检测到有无锡所设备接入,需要发送特定的数据,供检测 - // if (this.usbService.isWXUSBDevice) { - // const str = await senorToWXDataStr(msg); - // this.usbService.sendUSB(str) - // } - const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') - this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' - this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' - //TODO 暂时关闭差分检测异常 - // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); - if (!this.isExamEnd) { - await examJudgeRealExam(plcData) - } - let udpIndex = AppStorage.get('udpIndex'); - if (udpIndex % 5 === 0 && !this.isUdpEnd) { - // TODO UPD缺失 - // const judgeUdp = globalThis.judgeUdp - // const bytes = await this.getMessageHeartbeat(this.isExamEnd); - // judgeUdp.send(bytes) - } - AppStorage.setOrCreate('udpIndex', udpIndex++) - } //是否手动结束考试 private isManual: boolean //UDP服务序列号 @@ -264,6 +226,60 @@ export default class Judge { console.info(judgeTag, '过程数据文件上传 end') } private judgeTask: JudgeTask + // 检测扣分、结束项目时该项目是否开始 + checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: JudgeEventKf) => { + if (xmdm == 20) { + return true + } + const judgeUI = this.judgeUI; + const judgeTask = this.judgeTask; + const projectsObj = this.judgeUI.projectsObj + const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) + const isUpload = currentProject.isUpload + + //如果项目没有开始 + console.info('surenjun isUpload=>', isUpload) + if (!isUpload) { + console.info(judgeTag, '项目补传开始') + //项目开始补传 + judgeTask.addTask(async () => { + await this.beginProject(xmdm) + }, { + isDelay: true + }) + judgeTask.addTask(async () => { + await this.uploadProgressPhoto(xmdm) + }, { + isDelay: true + }) + currentProject.isUpload = true; + Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) + //扣分补传 + if (currentType == 2) { + judgeTask.addTask(async () => { + await this.pointsDedute(xmdm, kf) + }, { + isDelay: true + }) + } + //扣分补传判断是否合格 不合格补传项目结束 + if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) { + judgeTask.addTask(async () => { + await this.endProject(xmdm) + }, { + isDelay: true + }) + currentProject.isEnd = true; + Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) + } + judgeTask.addTask(async () => { + this.checkExamIsEnd() + }) + return false; + } else { + return true + } + } private tempData: Plc //实时计算gps经纬度距离 handDistance = async () => { @@ -427,6 +443,38 @@ export default class Judge { AppStorage.setOrCreate('msgStr', plc) return tempData } + // 处理udp plc信号 + handleUdp = async (msg: string) => { + console.info('plc信号', msg) + const stachArr = msg.split(',') + if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { + return + } + const plcData = await this.getPlcData(msg); + // 4.过程数据 + await this.fileLog.setExamJudgeData(JSON.stringify(plcData)) + //检测到有无锡所设备接入,需要发送特定的数据,供检测 + // if (this.usbService.isWXUSBDevice) { + // const str = await senorToWXDataStr(msg); + // this.usbService.sendUSB(str) + // } + const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') + this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' + this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' + //TODO 暂时关闭差分检测异常 + // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); + if (!this.isExamEnd) { + await examJudgeRealExam(plcData) + } + let udpIndex = AppStorage.get('udpIndex'); + if (udpIndex % 5 === 0 && !this.isUdpEnd) { + // TODO UPD缺失 + // const judgeUdp = globalThis.judgeUdp + // const bytes = await this.getMessageHeartbeat(this.isExamEnd); + // judgeUdp.send(bytes) + } + AppStorage.setOrCreate('udpIndex', udpIndex++) + } // 处理轨迹plc信号 handleTrajectoryUdp = async (strArr: string[]) => { // const { fileLog, setJudgeItem, setJudgeMark, endExam } = this; @@ -465,9 +513,9 @@ export default class Judge { } //本地轨迹回放地址 private trajectoryPath: string + //当前科目二的考试项目 // private currentKm2ItemsObj: any private isTrajectoryOpen: boolean; - //当前科目二的考试项目 // 调代理接口是否断网了 private isJudgeDisConnect: boolean; // 断网数据补传 @@ -482,67 +530,6 @@ export default class Judge { const code = await writeObjectOut(JSON.parse(examDataStr)); } } - // 考试过程照片 - uploadProgressPhoto = async (ksxm: number) => { - const time = GetCurrentTime(); - const judgeUI = this.judgeUI - const plcData = this.plcData - const photoBase64 = await this.getPhoto(); - const carInfo = AppStorage.get('carInfo'); - - const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) - const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305') - const drvexam: DrvexamType = { - lsh: judgeUI.lsh, - kskm: carInfo.examSubject, - ksxm: project.projectCodeCenter, - sfzmhm: judgeUI.idCard, - kchp: encodeURI(carInfo.plateNo), - zpsj: time, - zp: photoBase64, - cs: Math.floor((judgeConfig_305 == 0 ? plcData.gps.sd : plcData.sensor.cs) * 1.852), - ksdd: encodeURI(judgeUI.ksdd) - } - const data: RegulatoryInterfaceParams = { - xtlb: '17', - jkxlh: judgeUI.serialNumber, - jkid: '17C54', - drvexam - }; - const temp: WR = await this.sendWriteObjectOut(data, this.filePath); - if (temp.code === 2300007) { - this.isJudgeDisConnect = true - } - promptWxCode('17C54', temp.code) - console.info(judgeTag, '上传照片 end') - } - private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] - private lane: LANE = { - road: '', num: 0, count: 0 - } - private videoData: RecordHandleType - private disConnectNum: number = 0; - //调用监管接口 - sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { - const temp = await writeObjectOut(data, filePath); - console.log("wzj", JSON.stringify(temp)) - //断网&网络超时次数计算 - if (temp.code == 2300007 || temp.code == 2300028) { - this.disConnectNum += 1; - if (this.disConnectNum < 5) { - return await this.sendWriteObjectOut(data, filePath) - } - } - - if (this.disConnectNum >= 5) { - console.info('surenjun', '123') - this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!'; - this.judgeUI.disConnectErrorOpen = true - } - - this.disConnectNum = 0 - return temp - } // 项目开始接口同步 beginProject = async (ksxm: number) => { const carInfo = AppStorage.get('carInfo'); @@ -612,66 +599,73 @@ export default class Judge { console.info(judgeTag, '项目结束 end') promptWxCode('17C55', temp.code) } - // 检测扣分、结束项目时该项目是否开始 - checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: JudgeEventKf) => { - if (xmdm == 20) { - return true + private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] + private lane: LANE = { + road: '', num: 0, count: 0 + } + private videoData: RecordHandleType + private disConnectNum: number = 0; + //调用监管接口 + sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { + const temp = await writeObjectOut(data, filePath); + console.log("wzj", JSON.stringify(temp)) + //断网&网络超时次数计算 + if (temp.code == 2300007 || temp.code == 2300028) { + this.disConnectNum += 1; + if (this.disConnectNum < 5) { + return await this.sendWriteObjectOut(data, filePath) + } } - const judgeUI = this.judgeUI; - const judgeTask = this.judgeTask; - const projectsObj = this.judgeUI.projectsObj - const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) - const isUpload = currentProject.isUpload - //如果项目没有开始 - console.info('surenjun isUpload=>', isUpload) - if (!isUpload) { - console.info(judgeTag, '项目补传开始') - //项目开始补传 - judgeTask.addTask(async () => { - await this.beginProject(xmdm) - }, { - isDelay: true - }) - judgeTask.addTask(async () => { - await this.uploadProgressPhoto(xmdm) - }, { - isDelay: true - }) - currentProject.isUpload = true; - Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) - //扣分补传 - if (currentType == 2) { - judgeTask.addTask(async () => { - await this.pointsDedute(xmdm, kf) - }, { - isDelay: true - }) - } - //扣分补传判断是否合格 不合格补传项目结束 - if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) { - judgeTask.addTask(async () => { - await this.endProject(xmdm) - }, { - isDelay: true - }) - currentProject.isEnd = true; - Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) - } - judgeTask.addTask(async () => { - this.checkExamIsEnd() - }) - return false; - } else { - return true + if (this.disConnectNum >= 5) { + console.info('surenjun', '123') + this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!'; + this.judgeUI.disConnectErrorOpen = true } + + this.disConnectNum = 0 + return temp + } + // 考试过程照片 + uploadProgressPhoto = async (ksxm: number) => { + const time = GetCurrentTime(); + const judgeUI = this.judgeUI + const plcData = this.plcData + const photoBase64 = await this.getPhoto(); + const carInfo = AppStorage.get('carInfo'); + + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305') + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, + kskm: carInfo.examSubject, + ksxm: project.projectCodeCenter, + sfzmhm: judgeUI.idCard, + kchp: encodeURI(carInfo.plateNo), + zpsj: time, + zp: photoBase64, + cs: Math.floor((judgeConfig_305 == 0 ? plcData.gps.sd : plcData.sensor.cs) * 1.852), + ksdd: encodeURI(judgeUI.ksdd) + } + const data: RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: judgeUI.serialNumber, + jkid: '17C54', + drvexam + }; + const temp: WR = await this.sendWriteObjectOut(data, this.filePath); + if (temp.code === 2300007) { + this.isJudgeDisConnect = true + } + promptWxCode('17C54', temp.code) + console.info(judgeTag, '上传照片 end') } constructor(judgeUI: JudgeUI) { this.serialIndex = 1; this.judgeUI = judgeUI //语音播放工具 - this.avPlayer = new VoiceAnnounce(); + this.avPlayer = new VoiceAnnounce(this.context); //模型工具 this.fileModel = new FileModel(judgeUI.context); //文件工具 diff --git a/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets b/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets index dfadf8a5..0fc678f7 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets @@ -17,11 +17,11 @@ export default class VoiceAnnounce { //队列时候立马终止 private isStopped: Boolean private queue: Queue[] - private newQueue: Queue[] - private pendingQueue: String[] - private callback: Function; + private newQueue?: Queue[] + private context: common.UIAbilityContext - constructor() { + constructor(context: common.UIAbilityContext) { + this.context = context this.isStopped = false; this.queue = [] } @@ -60,16 +60,17 @@ export default class VoiceAnnounce { const queue = this.queue; const isStopped = this.isStopped; const newQueue = this.newQueue; - const avPlayer = new AVPlayer(); + const avPlayer = new AVPlayer(this.context); if (isStopped) { //清空原来队列 - this.queue = newQueue + this.queue = newQueue ?? [] this.isStopped = false; await go() return } console.info(TAG, '当前播放队列' + JSON.stringify(queue)) - await avPlayer.play(queue[0].url, queue[0].callback); + await avPlayer.play(queue[0].url, queue[0].callback || (() => { + })); this.queue.shift(); console.info(TAG, '当前播放队列播放完成退出'); avPlayer.avPlayerStop(); @@ -84,11 +85,11 @@ export default class VoiceAnnounce { class AVPlayer { public avPlayer?: media.AVPlayer; - private voiceUrl: string[]; - private voiceStatus: 'completed' | 'playing' - private endCallback: Function + private endCallback?: Function + private context: common.UIAbilityContext - constructor() { + constructor(context: common.UIAbilityContext) { + this.context = context } // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例 @@ -103,14 +104,14 @@ class AVPlayer { // console.info('surenjun fdPath=>',fdPath) console.info(TAG, 'audioPlayer => 准备加载资源播放') audioPlayer.on('dataLoad', () => { - this.voiceStatus = 'playing' + // this.voiceStatus = 'playing' console.info(TAG, 'audioPlayer => 播放资源开始') audioPlayer.play() }) return new Promise(async (resolve) => { audioPlayer.on('finish', () => { console.info(TAG, 'audioPlayer => 播放资源播放') - this.voiceStatus = 'completed' + // this.voiceStatus = 'completed' if (callback) { callback() } @@ -131,8 +132,7 @@ class AVPlayer { resolve(true) }); try { - const context: common.UIAbilityContext = AppStorage.get('context') - this.avPlayer.fdSrc = await context.resourceManager.getRawFd(name); + this.avPlayer.fdSrc = await this.context.resourceManager.getRawFd(name); } catch (e) { Prompt.showToast({ message: `${name}语音文件不存在`, @@ -195,14 +195,14 @@ class AVPlayer { case 'prepared': // prepare调用成功后上报该状态机 console.info(TAG, '播放资源播放') this.avPlayer.play(); - this.voiceStatus = 'playing' + // this.voiceStatus = 'playing' break; case 'playing': // play成功调用后触发该状态机上报 break; case 'paused': // pause成功调用后触发该状态机上报 break; case 'completed': // 播放结束后触发该状态机上报 - this.voiceStatus = 'completed' + // this.voiceStatus = 'completed' this.avPlayer.stop(); //调用播放结束接口 break; case 'stopped': // stop接口成功调用后触发该状态机上报