diff --git a/entry/src/main/ets/pages/CarCheck.ets b/entry/src/main/ets/pages/CarCheck.ets index bd87e65..f1651c9 100644 --- a/entry/src/main/ets/pages/CarCheck.ets +++ b/entry/src/main/ets/pages/CarCheck.ets @@ -41,7 +41,17 @@ struct Index { @State devPath: string = "/dev/ttyS3" @State stopFlag: boolean = false @State fromIndex: boolean = false - @State carInfo: CarInfoType = {} + @State carInfo: CarInfoType = { + carId: '', + examinationRoomId: '', + plateNo: '', + carNo: '', + examSubject: 'C1', + isNeedCheck: '0', + udpAddress: '', + messagePort: '', + hintPort: '' + } private vocObj?: voiceService; private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext diff --git a/entry/src/main/ets/pages/compontents/FaceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets index d77d38a..7ad517a 100644 --- a/entry/src/main/ets/pages/compontents/FaceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -38,7 +38,9 @@ export default struct FaceCompare { @State showControls: boolean = false @State isAutoPlay: boolean = true @State signNum: number = 0; - @State carInfo: CarInfoType = {}; + @State carInfo: CarInfoType = { + + }; @State param: VideoConfig = VideoConfigData private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 private vocObj!: voiceService; diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index fc49f53..e675df8 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -706,7 +706,7 @@ export default class Judge { getJudgeInitData = async () => { const carInfo = AppStorage.get('carInfo'); const judgeUI = this.judgeUI - const projectsObj = judgeUI.projectsObj + // const projectsObj = judgeUI.projectsObj const itemInfoObj = judgeUI.itemInfoObj const markRuleListObj = judgeUI.markRuleListObj const carType = judgeUI.carType @@ -721,9 +721,9 @@ export default class Judge { const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); const model = this.getModelData(`${examType}/${cdsb.modelKey}.txt`) const temp: ItemInfo = { - xmdm: cdsb?.xmdm||0, - xmxh: cdsb?.xmxh||"", - model:model||"" + xmdm: cdsb?.xmdm || 0, + xmxh: cdsb?.xmxh || "", + model: model || "" } return temp }) @@ -736,14 +736,14 @@ export default class Judge { }) const initInfo: JudgeInitObj = { sdkver: await examJudgeVersion(), - appver: AppStorage.get('baseInfo')?.version||"", - kskm: Number(carInfo?.examSubject||"2"), - kchp: carInfo?.plateNo||"", - kchm: Number(carInfo?.carId||""), + appver: AppStorage.get('baseInfo')?.version || "", + kskm: Number(carInfo?.examSubject || "2"), + kchp: carInfo?.plateNo || "", + kchm: Number(carInfo?.carId || ""), kscx: carType, cxcode: '1', name: carName, - carmodel: this.getModelData(`${examType}/${carType}.txt`)||"", + carmodel: this.getModelData(`${examType}/${carType}.txt`) || "", allitems, iteminfo: [], systemparm: systemparmArr, @@ -772,7 +772,7 @@ export default class Judge { getJudgeBeginData = async () => { const examinerInfo = AppStorage.get('examinerInfo') // const code = examinerInfo.code - const examinerName = examinerInfo?.name||"" + const examinerName = examinerInfo?.name || "" let currentParams: RouteParamsType = router.getParams() as RouteParamsType; const sczb = currentParams.sczb; @@ -893,9 +893,9 @@ export default class Judge { this.rmndg = 1 } this.judgeUI.currentXmdm = xmdm; - const xmmcStr = project.name||""; - const xmmcCode = project.projectCodeCenter||""; - const xmmcSingleCode = project.projectCode||""; + const xmmcStr = project?.name || ""; + const xmmcCode = project?.projectCodeCenter || ""; + const xmmcSingleCode = project?.projectCode || ""; const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) kmItem.status = 2; this.xmmcStr = xmmcStr; @@ -906,13 +906,13 @@ export default class Judge { this.xmxh = xmxh; this.judgeUI.isProjectIn = true Reflect.set(this.judgeUI.projectsObj, xmdm, project) - Reflect.set(this.kmItems, xmmcCode||0, kmItem) + Reflect.set(this.kmItems, xmmcCode || 0, kmItem) break; //项目结束 case 2: { const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) - const xmmcCode = project.projectCodeCenter||""; + const xmmcCode = project.projectCodeCenter || ""; project.type = (xmjs.xmhg === 0 ? '4' : '3') //计算项目是否全部结束 @@ -954,9 +954,9 @@ export default class Judge { //扣分类型 type: kf.type } - //扣分信息 - this.kfArr.push(kfObj) - this.judgeUI.totalScore += thisKf.score * 1; + //扣分信息 + this.kfArr?.push(kfObj) + this.judgeUI.totalScore += Number(thisKf?.score); if (kf.xmdm != 20) { const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm) const type = project.type; @@ -984,7 +984,7 @@ export default class Judge { const xmdm = xmqx.xmdm; const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) // const examSubject = this.judgeUI.examSubject - const xmmcCode = project.projectCodeCenter||""; + const xmmcCode = project.projectCodeCenter || ""; // const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); // avPlayer.playAudio([`voice/${voiceCode}.mp3`],true) project.type = '1' @@ -1016,19 +1016,20 @@ export default class Judge { const param611: JudgeConfigObj = Reflect.get(judgeConfigObj, '611') || '' const xmdm = precast.xmdm const xmxh = precast.xmxh + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) - const xmmcCode = project.projectCodeCenter||"" const projectCode = project.projectCode - // const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - // const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; + const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; + const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) + const xmmcStr = project?.name || ""; kmItem.status = 2; Reflect.set(this.kmItems, xmmcCode, project) - this.xmmcStr = xmmcStr; - this.xmmcCode = xmmcCode; + this.xmmcStr = xmmcStr||""; + this.xmmcCode = xmmcCode||""; this.xmdm = xmdm; this.xmxh = xmxh; - this.xmmcSingleCode = xmmcSingleCode; + this.xmmcSingleCode = xmmcSingleCode||""; project.type = '2'; Reflect.set(this.judgeUI.projectsObj, xmdm, project) } @@ -1046,7 +1047,7 @@ export default class Judge { }); //语音播报 - this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs, ksjs, xmxh) + this.goVoiceAnnounce(event, xmdm, this.kfArr||[], xmjs, ksjs, xmxh) //更新UI if (event == 1 || event == 2 || event == 3 || event == 6) { const copyProjectsObj = this.judgeUI.projectsObj; @@ -1088,21 +1089,21 @@ export default class Judge { const project: ProjectInfo = Reflect.get(projectsObj, xmdm) const code = project.projectCodeCenter; const isEnd = project.isEnd; - // const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) - // if (!ignoreVoiceCodeArr.includes(code)) { - // if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){ - // //倒出入库、桩考\进项目语音控制 - // }else{ - // kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) - // } - // } + // const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) + // if (!ignoreVoiceCodeArr.includes(code)) { + // if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){ + // //倒出入库、桩考\进项目语音控制 + // }else{ + // kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) + // } + // } setTimeout(() => { if (Reflect.get(param512, 7) != 0) { clearTimeout(this.deductedPopShowTimer) this.judgeUI.isDeductedPopShow = true } }, 200) - //项目已考不上传监管信息 + //项目已考不上传监管信息 if (!isEnd) { judgeTask.addTask(async () => { console.info(judgeTag, `项目开始-${xmdm}-${project.name}`) @@ -1148,7 +1149,7 @@ export default class Judge { if (!this.judgeUI.isProjectIn) { this.deductedPopShowTimer = setTimeout(() => { this.judgeUI.isDeductedPopShow = false - }, (Reflect.get(param512, 5) || 0) * 1000) + }, (Reflect.get(param512!, 5) || 0) * 1000) } project.isEnd = true; Reflect.set(this.judgeUI.projects, xmdm, project) @@ -1158,11 +1159,11 @@ export default class Judge { // 扣分 case 3: console.info('surenjun', '扣分开始') - //扣分时实时播报语音(0-否+1-是) + //扣分时实时播报语音(0-否+1-是) const currentKf = kf[kfLen -1]; if (JudgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '1') || (examSubject == '3' && judgeConfigObj['418'] == '1')) { - avPlayer.playAudio([`voice/${currentKf.markcatalog}.mp3`, `voice/mark_${Math.abs(currentKf.score)}.mp3`]) + avPlayer?.playAudio([`voice/${currentKf.markcatalog}.mp3`, `voice/mark_${Math.abs(currentKf?.score||0)}.mp3`]) } const isStart = await checkProjectIsStart(Number(currentKf.xmdm), 2, currentKf); if (isStart) { @@ -1182,9 +1183,9 @@ export default class Judge { // 考试结束 case 5: console.info(judgeTag, '考试结束') - //关闭录像 + //关闭录像 const singlePlay = AppStorage.get('singlePlay') - if (!singlePlay) { + if (!singlePlay&&this.videoData) { await endRecordVideo(this.videoData) } judgeTask.addTask(async () => { @@ -1192,8 +1193,8 @@ export default class Judge { AppStorage.setOrCreate('isJudge', false) await handEndExam(ksjs) }) - // TODO待修改 - // clearInterval(globalThis.judgeTimer) + // TODO待修改 + // clearInterval(globalThis.judgeTimer) break default: break @@ -1211,15 +1212,15 @@ export default class Judge { } // 考试扣分 pointsDedute = async (ksxm: number, kf: MarkRule) => { - const carInfo = AppStorage.get('carInfo'); + const carInfo = AppStorage.get('carInfo')!; const examSubject = carInfo.examSubject - const plateNo = carInfo.plateNo - const carNo = carInfo.carNo + // const plateNo = carInfo.plateNo + // const carNo = carInfo.carNo const judgeUI = this.judgeUI - const getProjectInfo = this.getProjectInfo - const fileLog = this.fileLog - const xmmcSingleCode = this.xmmcSingleCode + // const getProjectInfo = this.getProjectInfo + // const fileLog = this.fileLog + // const xmmcSingleCode = this.xmmcSingleCode const xmmcEndCode = this.xmmcEndCode const filePath = this.filePath @@ -1248,7 +1249,7 @@ export default class Judge { const ksxmD: string = project == undefined ? (commonKsxm - ? (project.projectCodeCenter) + ? (project?.projectCodeCenter||"") : (examSubject == '3' ? '30000' : (xmmcEndCode == undefined ? '10000' : xmmcEndCode))) : project.projectCodeCenter const drvexam: DrvexamType = { @@ -1258,7 +1259,7 @@ export default class Judge { kfxm: kf.markcatalog, kfxmmx: `${ksxm},${kf.markserial}`, sfzmhm: idCard, - kchp: encodeURI(carInfo.plateNo), + kchp: encodeURI(carInfo?.plateNo||""), //扣分方式 kffs: kf.type == 0 ? 1 : 2, ksdd: encodeURI(ksdd), @@ -1270,14 +1271,14 @@ export default class Judge { jkid: '17C53', drvexam } - console.info(judgeTag + 'ksxm=>', data.drvexam.ksxm) + // console.info(judgeTag + 'ksxm=>', data.drvexam.ksxm) const temp = await this.sendWriteObjectOut(data, filePath); if (temp.code == 2300007) { this.isJudgeDisConnect = true } console.info(judgeTag, '项目扣分 end') - promptWxCode('17C53', temp.code) + promptWxCode('17C53', temp?.code||0) } // 评判语音提示 goJudgeVoice = async (sound: JudgeSound) => { @@ -1286,11 +1287,11 @@ export default class Judge { console.info('surenjun code=>', JSON.stringify(sound.code)) //判断是不是模拟灯光语音 if (sound.type == 1) { - avPlayer.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { + avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { examJudgeSoundEnd({ xmdm: sound.xmdm, code: sound.code[0], type: sound.type }) - fileLog.setExamJudgeData(JSON.stringify({ + fileLog?.setExamJudgeData(JSON.stringify({ method: 'examJudgeSoundEnd', itemno: sound.xmdm, code: sound.code[0], @@ -1298,7 +1299,7 @@ export default class Judge { })) }) } else { - avPlayer.playAudio([`voice/${sound.code[0]}.mp3`]) + avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`]) } } // 处理考试结束 @@ -1331,11 +1332,11 @@ export default class Judge { //自动退出待验证并且不合格 if (!isManual && examSubject == '3' && (param302 == '1' || (singlePlay && param302 == '2')) && totalScore < passingScore) { - avPlayer.playAudio([`voice/考试结束.mp3`]) + avPlayer?.playAudio([`voice/考试结束.mp3`]) } //联网模式下手动结束的直接退出 if (!singlePlay && isManual && !isAllProjectsEnd) { - avPlayer.playAudio(['voice/empty.mp3'], true, () => { + avPlayer?.playAudio(['voice/empty.mp3'], true, () => { this.isUdpEnd = true; closeAllFiles() router.back(); @@ -1352,7 +1353,7 @@ export default class Judge { } } await handleSEP(306); - avPlayer.playAudio(['voice/exam_waiting.mp3'], AppStorage.get('singlePlay'), async () => { + avPlayer?.playAudio(['voice/exam_waiting.mp3'], AppStorage.get('singlePlay'), async () => { try { if (!singlePlay) { // TODO const bytes = await this.getMessageHeartbeat(true); @@ -1367,10 +1368,10 @@ export default class Judge { } // 考试结束 public endExam = async (isManual?: Boolean) => { - const carInfo = AppStorage.get('carInfo'); - const singlePlay = AppStorage.get('singlePlay') - const examSubject = carInfo.examSubject - const plateNo = carInfo.plateNo + const carInfo = AppStorage.get('carInfo')!; + const singlePlay = AppStorage.get('singlePlay')||false + const examSubject = carInfo?.examSubject||"2" + const plateNo = carInfo?.plateNo||"" const judgeUI = this.judgeUI const ksjs = this.ksjs @@ -1392,11 +1393,11 @@ export default class Judge { // await uploadDisConnectData(); const time = GetCurrentTime(); const photoBase64 = await getPhoto(); - const d1 = ksjs.d1; - const d2 = ksjs.d2; - const d3 = ksjs.d3; - const d4 = ksjs.d4; - const d5 = ksjs.d5; + const d1 = ksjs?.d1||0; + const d2 = ksjs?.d2||0; + const d3 = ksjs?.d3||0; + const d4 = ksjs?.d4||0; + const d5 = ksjs?.d5||0; const drvexam: DrvexamType = { lsh, @@ -1406,7 +1407,7 @@ export default class Judge { zp: photoBase64, jssj: time, kscj: (totalScore * 1) > 0 ? totalScore : 0, - kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100), + kslc: Math.ceil(((ksjs?.qjjl ?? 0) + (ksjs?.dcjl ?? 0)) / 100), // 1,22;2,560;3,128;4,0;5,0; dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'), } @@ -1421,11 +1422,11 @@ export default class Judge { router.back() }, 90 * 1000) const temp = await this.sendWriteObjectOut(data, filePath); - promptWxCode('17C56', temp.code) + promptWxCode('17C56', temp?.code||0) if (temp.code != 1) { - avPlayer.playAudio(['voice/监管失败.mp3']) - this.judgeUI.errorMsg = decodeURIComponent(temp.message) + avPlayer?.playAudio(['voice/监管失败.mp3']) + this.judgeUI.errorMsg = decodeURIComponent(temp?.message||"") if (temp.code == 2300028 || temp.code == 2300007) { this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' @@ -1504,24 +1505,24 @@ export default class Judge { let score = 0; //结束考试时候是否播报一遍所有扣分 const param634: string = Reflect.get(judgeConfigObj, '634') - if (kfArr.length && ((examSubject == '2' && param634 == '1') || examSubject == '3')) { - avPlayer.playAudio([`voice/kfdesc.mp3`], false, () => { + if (kfArr&&kfArr.length && ((examSubject == '2' && param634 == '1') || examSubject == '3')) { + avPlayer?.playAudio([`voice/kfdesc.mp3`], false, () => { try { kfArr.forEach((kf, index) => { score += Math.abs(Number(kf.score)); //TODO 考试分数待替换 if (score <= (examSubject == '3' ? 10 : 20)) { - if (kfArr.length - 1 === index) { - avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { + if (kfArr&&kfArr.length - 1 === index) { + avPlayer?.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; closeAllFiles() router.back(); }) throw new Error('End Loop') } - avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`]) + avPlayer?.playAudio([`voice/${kf.markcatalog}.mp3`]) } else { - avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { + avPlayer?.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; closeAllFiles() router.back(); @@ -1534,7 +1535,7 @@ export default class Judge { } }) } else { - avPlayer.playAudio([voiceURL], true, () => { + avPlayer?.playAudio([voiceURL], true, () => { setTimeout(() => { this.isUdpEnd = true closeAllFiles() @@ -1691,7 +1692,8 @@ export default class Judge { return '0000000000' } const projectKey = `${ksxm}_${xmxh}`; - const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + // const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + const currentCdsb: CDSBInfo = (Reflect.get(cdsbInfoObj, projectKey) ?? {}) as CDSBInfo; const sbxh: string = currentCdsb.sbbh || '0000000000' return sbxh } @@ -1750,7 +1752,7 @@ export default class Judge { } // 获取模型数据 getModelData = (modelName: string) => { - const modelData = this.fileModel.getModelContent(this.modelPath, modelName); + const modelData = this.fileModel?.getModelContent(this.modelPath, modelName); return modelData } // 统计必考项目、所有项目、已考数量 @@ -1795,30 +1797,30 @@ export default class Judge { case 1: this.judgeUI.dwztErrorVisible = true; - avPlayer.playAudio([`voice/差分状态异常.mp3`], true) + avPlayer?.playAudio([`voice/差分状态异常.mp3`], true) setTimeout(() => { router.back() }, 3000) break; case 2: - avPlayer.playAudio([`voice/差分状态异常.mp3`], true); + avPlayer?.playAudio([`voice/差分状态异常.mp3`], true); break; case 3: this.judgeUI.dwztErrorVisible = true; - avPlayer.playAudio([`voice/差分状态异常.mp3`], true); + avPlayer?.playAudio([`voice/差分状态异常.mp3`], true); break; case 4: this.judgeUI.isDwztRight = false; - //差分异常上报 + //差分异常上报 break; } } closeAllFiles = () => { setTimeout(() => { - this.fileLog.closeAllFiles() + this.fileLog?.closeAllFiles() }, 1000) } @@ -1833,7 +1835,7 @@ export default class Judge { const manualMarkRules = judgeUI.manualMarkRules const fileLog = new FileLog(judgeUI.context); - const filePath = await fileLog.initFileLogo({ + const filePath = await fileLog?.initFileLogo({ name, lsh, idCard }); this.fileLog = fileLog; @@ -1858,13 +1860,13 @@ export default class Judge { console.info(judgeTag, '1.进入评判入口') await examJudgeSetLogCallback(3, async (level: number, info: string, len: number) => { console.log('评判日志:' + info) - await fileLog.setExamJudgeLogData(info); + await fileLog?.setExamJudgeLogData(info); }) console.info(judgeTag, '2.注册日志回调完成') let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); - await fileLog.setExamJudgeData(JSON.stringify(initInfo)) + await fileLog?.setExamJudgeData(JSON.stringify(initInfo)) //相关评判初始化只做一次 if (!isJudgeInitBool) { const tempJudge = await examJudgeInit(initInfo); @@ -1874,7 +1876,7 @@ export default class Judge { AppStorage.setOrCreate('isJudge', true) // 2.评判过程回调 await examJudgeSetRealExamCallback(async (strData: string, len: number) => { - await fileLog.setExamJudgeCallbackData(strData) + await fileLog?.setExamJudgeCallbackData(strData) console.info('评判回调数据', strData) this.handleRealExam(strData, callBack) }) @@ -1892,7 +1894,7 @@ export default class Judge { // globalThis.laneData = performInfo.lane; }) - let beginExamInfo: JudgeBeginObj = undefined + let beginExamInfo: JudgeBeginObj|undefined = undefined // 3.开始考试 if (isTrajectoryOpen) { beginExamInfo = JSON.parse(strArr[1]) @@ -1900,10 +1902,10 @@ export default class Judge { } else { beginExamInfo = await getJudgeBeginData() } - await fileLog.setExamJudgeData(JSON.stringify(beginExamInfo)) + await fileLog?.setExamJudgeData(JSON.stringify(beginExamInfo)) await examJudgeBeginExam(beginExamInfo); console.info(judgeTag, '6.开始考试注册完成') - avPlayer.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) + avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) if (!judgeUI.singlePlay) { this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, this.context)