diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index bcccc60d..19e1fdfd 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -54,59 +54,6 @@ struct Index { }), - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - customStyle: true, alignment: DialogAlignment.Center, }) @@ -507,7 +454,6 @@ struct Index { } }) }); - } aboutToDisappear() { @@ -518,10 +464,6 @@ struct Index { if (this.loading) { return } - // let mode=globalThis.timeInfo?.mode?globalThis.timeInfo?.mode:1 - - // console.log('mode',mode) - const param = { carId: globalThis.carInfo?.carId, examinationRoomId: globalThis.carInfo?.examinationRoomId, @@ -536,30 +478,18 @@ struct Index { singlePlay: globalThis.singlePlay } this.loading = true - console.log("sql 1111") getSingleCenterTable(param).then((ret) => { - console.log('teststetfinsh1', ret) - // DB.queryListBySql('select * from MA_SYSSET', [{ - // name: "v_no", - // type: ColumnType.STRING, - // columnName: "v_no" - // }]).then((res) => { - // console.log('sql success', JSON.stringify(res)) - // }).catch((err) => { - // console.log('sql error1', err) - // }) + console.log('getSingleCenterTable finish', ret) if (ret) { - getSyncData('MA_SYSSET').then(data => { - console.log('datadata', JSON.stringify(data)) - // @ts-ignore + getSyncData('MA_SYSSET').then((data: any[]) => { + console.log('MA_SYSSET data', JSON.stringify(data)) 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: { @@ -572,9 +502,12 @@ struct Index { }, router.RouterMode.Single) } }) + }).finally(() => { + this.loading = false }); - } + }).finally(() => { + this.loading = false }) } @@ -623,9 +556,7 @@ struct Index { globalThis.singlePlay = false } this.isSingle = globalThis.singlePlay - // this.loading = false this.num = 0 - // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) globalThis.lsh = '1111111111111' } @@ -666,7 +597,6 @@ struct Index { console.error(`Failed to request permissions from user. Code is ${err.code}, message is ${err.message}`); }) }) - } async initParams() { diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 9515c312..156645b9 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -109,7 +109,6 @@ struct UserInfo { if (this.ksksLimit) { return } - console.log('routerParamrouterParam') try { await this.checkSignal() this.faceCompareSucess = 0 @@ -140,7 +139,6 @@ struct UserInfo { // 同一学员连续第二次考试时不再验证身份 if (this.currentUser.kssycs == '1' && this.systemParam.Param830Str == '1') { this.sfbdinterfaceFn() - } else { this.ksksLimit = false this.showFaceCompare = true @@ -891,14 +889,24 @@ struct UserInfo { const {carId,examinationRoomId} = carInfo; let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } }; if (!globalThis.singlePlay) { - //获取已考项目 - // @ts-ignore - examItems = await getExaminationItem({ - time: getCurrentTime(), - carId, - lsh: this.currentUser.lsh || '', - examinationRoomId - }) + try { + //获取已考项目 + // @ts-ignore + examItems = await getExaminationItem({ + time: getCurrentTime(), + carId, + lsh: this.currentUser.lsh || '', + examinationRoomId + }) + } catch (e) { + promptAction.showToast({ + message: "获取考试信息失败,请重试", + duration: 3000 + }) + this.isLoadingPopupVisible = false + this.isExamStart = false + return + } } this.currentUser.id = '1' const avPlayer = this.avPlayer; @@ -906,38 +914,45 @@ struct UserInfo { avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => { console.info('surenjun', '播放结束开始考试接口调用') - const {code,keystr,message} = await this.beginExam() || {}; - console.info('surenjun', '开始考试接口调用结束') - // console.info('surenjun',code +'') - //@ts-ignore TODO code转换 - - if (code != 1) { - avPlayer.playAudio([code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']); + try { + const {code,keystr,message} = await this.beginExam() || {}; + console.info('surenjun', '开始考试接口调用结束') + if (code != 1) { + avPlayer.playAudio([code == -200 ? 'voice/photo_error.mp3' : 'voice/监管审核未通过.mp3']); + this.isLoadingPopupVisible = false + this.isExamStart = false + promptAction.showToast({ + message, + duration: 4000 + }) + return + } + this.currentUser.id = '0' + await upDateTableByArray('USER', [this.currentUser]) + this.stepFlag = false + this.isLoadingPopupVisible = false + router.pushUrl({ + url: 'pages/Judge', + params: { + examItems: examItems?.getExaminationItemRsp?.body?.ykxx, + sczb: Number(this.isBoardPrePareSetPopupOpen), + kfdm: this.sczbkf, + //真实监管项目 + kString: decodeURIComponent(keystr || '') + } + }, router.RouterMode.Single); + this.updateTimeLimit = false + this.stopDeviceById() + this.stepFlag = false + } catch (e) { + promptAction.showToast({ + message: "监管审核失败,请重试", + duration: 3000 + }) this.isLoadingPopupVisible = false this.isExamStart = false - promptAction.showToast({ - message, - duration: 4000 - }) return } - this.currentUser.id = '0' - await upDateTableByArray('USER', [this.currentUser]) - this.stepFlag = false - this.isLoadingPopupVisible = false - router.pushUrl({ - url: 'pages/Judge', - params: { - examItems: examItems?.getExaminationItemRsp?.body?.ykxx, - sczb: Number(this.isBoardPrePareSetPopupOpen), - kfdm: this.sczbkf, - //真实监管项目 - kString: decodeURIComponent(keystr || '') - } - }, router.RouterMode.Single); - this.updateTimeLimit = false - this.stopDeviceById() - this.stepFlag = false }) } @@ -1097,9 +1112,7 @@ struct UserInfo { }).catch(err => { console.log("USER insert fail", JSON.stringify(err)) }) - // await upDateTableByArray('USER', [this.currentUser]) console.log("User", JSON.stringify(this.currentUser)) - // await sqlInsertCommonFn("USER", [this.currentUser]) globalThis.statue = 4 this.isBoardPrePareSetPopupShow = true; this.isFirstBoardPrePareSetPopupBtnShow = true; @@ -1284,9 +1297,9 @@ struct UserInfo { return } //835参数值和预约考试次数对比 - if(Number(this.systemParam.Param835)<=Number(this.currentUser.yycs)&&!globalThis.singlePlay){ - this.type='4' - this.title='当前考生预约考试次数为'+this.currentUser.yycs + if (Number(this.systemParam.Param835) <= Number(this.currentUser.yycs) && !globalThis.singlePlay) { + this.type = '4' + this.title = '当前考生预约考试次数为' + this.currentUser.yycs this.errorDialog.open() return } @@ -1446,5 +1459,5 @@ type systemParam = { 'Param830Str': string, //同一学员连续第二次考试时不再验证身份 'Param364': string, //考前上车准备 'Param398': string, //考前上车准备 - 'Param835' :string + 'Param835': string } \ No newline at end of file diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index 0d9d3833..4ca85062 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -54,6 +54,7 @@ import { examJudgeVersion } from './api/index'; import { getSyncData, upDateTableByArray } from '../../common/service/initable'; +import promptAction from '@ohos.promptAction'; const judgeTag = 'SURENJUN_JUDGE' @@ -382,10 +383,10 @@ export default class Judge { //成绩不合格 if (totalScore < passingGrade) { //科目三不合格报靠边停车 - if (examSubject == 3 ) { - if( param302 == 1){ + if (examSubject == 3) { + if (param302 == 1) { avPlayer.playAudio([`voice/考试结束.mp3`]); - }else if(param302 == 0){ + } else if (param302 == 0) { return } } @@ -895,7 +896,7 @@ export default class Judge { //扣分 case 3: const thisKf = getKfStr(`${kf.xmdm}_${kf.kfdm}`) - //扣分信息 + //扣分信息 this.kfArr.push({ //扣分项目名称 xmmcStr: getDqxmStr(kf.xmdm), @@ -1037,20 +1038,20 @@ export default class Judge { const code = projectsObj[xmdm].projectCodeCenter; const isEnd = projectsObj[xmdm].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) - // } - // } + // 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 (param512[7] != 0) { clearTimeout(this.deductedPopShowTimer) this.judgeUI.isDeductedPopShow = true } }, 200) - //项目已考不上传监管信息 + //项目已考不上传监管信息 if (!isEnd) { judgeTask.addTask(async () => { console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`) @@ -1103,7 +1104,7 @@ 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')) { @@ -1127,7 +1128,7 @@ export default class Judge { // 考试结束 case 5: console.info(judgeTag, '考试结束') - //关闭录像 + //关闭录像 if (!globalThis.singlePlay) { await endRecordVideo(this.videoData) } @@ -1226,7 +1227,7 @@ export default class Judge { }) } else { //收到综合评判语音时,显示综合评判弹窗 - if(code[0] == 'zhpp'){ + if (code[0] == 'zhpp') { clearTimeout(this.deductedPopShowTimer) this.judgeUI.isDeductedPopShow = true this.judgeUI.defaultTabIndex = 1 @@ -1298,135 +1299,142 @@ export default class Judge { judgeUI, ksjs, getPhoto, - uploadProgressData, - uploadDisConnectData, avPlayer, kfArr, - judgeTask, filePath, closeAllFiles } = this; const { lsh, idCard, serialNumber, kssycs, totalScore, judgeConfigObj, isAllProjectsEnd, passingScore } = judgeUI //TODO 断网考试结束补传 // await uploadDisConnectData(); - const time = await getCurrentTime(); - const photoBase64 = await getPhoto(); - const { d1, d2, d3, d4, d5 } = ksjs - const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C56', - drvexam: { - lsh, - kchp: encodeURI(plateNo), - kskm: examSubject, - sfzmhm: idCard, - //@ts-ignore - zp: photoBase64, - jssj: time, - kscj: (totalScore * 1) > 0 ? totalScore : 0, - kslc: Math.ceil(((ksjs?.qjjl + 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(';'), + try { + const time = await getCurrentTime(); + const photoBase64 = await getPhoto(); + const { d1, d2, d3, d4, d5 } = ksjs + const data = { + xtlb: '17', + jkxlh: serialNumber, + jkid: '17C56', + drvexam: { + lsh, + kchp: encodeURI(plateNo), + kskm: examSubject, + sfzmhm: idCard, + //@ts-ignore + zp: photoBase64, + jssj: time, + kscj: (totalScore * 1) > 0 ? totalScore : 0, + kslc: Math.ceil(((ksjs?.qjjl + 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(';'), + } } - } - let backTimeOut = setTimeout(() => { - router.back() - }, 90 * 1000) - const { code, keystr, message } = await this.sendWriteObjectOut(data, filePath); - promptWxCode('17C56', code) + let backTimeOut = setTimeout(() => { + router.back() + }, 90 * 1000) + const { code, keystr, message } = await this.sendWriteObjectOut(data, filePath); + promptWxCode('17C56', code) - if (code != 1) { - avPlayer.playAudio(['voice/监管失败.mp3']) - this.judgeUI.errorMsg = decodeURIComponent(message) + if (code != 1) { + avPlayer.playAudio(['voice/监管失败.mp3']) + this.judgeUI.errorMsg = decodeURIComponent(message) - if (code == 2300028 || code == 2300007) { - this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' + if (code == 2300028 || code == 2300007) { + this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' + } + this.isUdpEnd = true; + closeAllFiles() + this.judgeUI.loadingPopupVisible = false; + return } - this.isUdpEnd = true; - closeAllFiles() - this.judgeUI.loadingPopupVisible = false; - return - } - console.info(judgeTag, '考试结束 end') - const param302 = judgeConfigObj['302']; - judgeUI.loadingPopupVisible = true; - let currentKssycs = 0; - let voiceURL = '' - if (examSubject == 2) { - if (isAllProjectsEnd) { - voiceURL = - (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') - } else { - voiceURL = `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` - currentKssycs = kssycs == 1 ? 0 : 1 - } - switch (voiceURL) { - case 'voice/unqualified_one.wav': - currentKssycs = 0; - break; + console.info(judgeTag, '考试结束 end') + const param302 = judgeConfigObj['302']; + judgeUI.loadingPopupVisible = true; + let currentKssycs = 0; + let voiceURL = '' + if (examSubject == 2) { + if (isAllProjectsEnd) { + voiceURL = + (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') + } else { + voiceURL = `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` + currentKssycs = kssycs == 1 ? 0 : 1 + } + switch (voiceURL) { + case 'voice/unqualified_one.wav': + currentKssycs = 0; + break; - case 'voice/unqualified_two.wav': - currentKssycs = 1; - break; + case 'voice/unqualified_two.wav': + currentKssycs = 1; + break; - case 'voice/qualified.mp3': - currentKssycs = 0; - break; + case 'voice/qualified.mp3': + currentKssycs = 0; + break; + } } - } - if (examSubject == 3) { - if (isAllProjectsEnd) { - if (totalScore < passingScore) { + if (examSubject == 3) { + if (isAllProjectsEnd) { + if (totalScore < passingScore) { + voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` + currentKssycs = kssycs == 1 ? 0 : 1 + } else { + voiceURL = 'voice/exam_pass.mp3' + currentKssycs = 0 + } + } else { voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` currentKssycs = kssycs == 1 ? 0 : 1 - } else { - voiceURL = 'voice/exam_pass.mp3' - currentKssycs = 0 } - } else { - voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` - currentKssycs = kssycs == 1 ? 0 : 1 + switch (voiceURL) { + case 'voice/exam_no_pass_finish.mp3': + currentKssycs = 0; + break; + + case 'voice/exam_no_pass.mp3': + currentKssycs = 1; + break; + + case 'voice/exam_pass.mp3': + currentKssycs = 0; + break; + + } } - switch (voiceURL) { - case 'voice/exam_no_pass_finish.mp3': - currentKssycs = 0; - break; - case 'voice/exam_no_pass.mp3': - currentKssycs = 1; - break; - - case 'voice/exam_pass.mp3': - currentKssycs = 0; - break; + const USER = await getSyncData('USER'); + await upDateTableByArray('USER', [{ + ...USER[0], + kssycs: currentKssycs + }]) + console.info(judgeTag, `考试成绩:${totalScore}`) + if (!singlePlay) { + // await uploadProgressData(); } - } - - const USER = await getSyncData('USER'); - await upDateTableByArray('USER', [{ - ...USER[0], - kssycs: currentKssycs - }]) - - console.info(judgeTag, `考试成绩:${totalScore}`) - if (!singlePlay) { - // await uploadProgressData(); - } - clearTimeout(backTimeOut) - //语音播放扣分项 - let score = 0; - //结束考试时候是否播报一遍所有扣分 - const param634 = judgeConfigObj['634']; - if (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) { + clearTimeout(backTimeOut) + //语音播放扣分项 + let score = 0; + //结束考试时候是否播报一遍所有扣分 + const param634 = judgeConfigObj['634']; + if (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, () => { + this.isUdpEnd = true; + closeAllFiles() + router.back(); + }) + throw new Error('End Loop') + } + avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`]) + } else { avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; closeAllFiles() @@ -1434,28 +1442,27 @@ export default class Judge { }) throw new Error('End Loop') } - avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`]) - } else { - avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { - this.isUdpEnd = true; - closeAllFiles() - router.back(); - }) - throw new Error('End Loop') - } - }) - } catch (e) { - console.info(judgeTag, JSON.stringify(e)) - } - }) - } else { - avPlayer.playAudio([voiceURL], true, () => { - setTimeout(() => { - this.isUdpEnd = true - closeAllFiles() - router.back(); - }, param302 == 8 ? 3000 : 0) + }) + } catch (e) { + console.info(judgeTag, JSON.stringify(e)) + } + }) + } else { + avPlayer.playAudio([voiceURL], true, () => { + setTimeout(() => { + this.isUdpEnd = true + closeAllFiles() + router.back(); + }, param302 == 8 ? 3000 : 0) + }) + } + + } catch (e) { + promptAction.showToast({ + message: "考试结束异常,请尝试重新结束", + duration: 3000 }) + judgeUI.loadingPopupVisible = false } } @@ -1742,7 +1749,7 @@ export default class Judge { case 4: this.judgeUI.isDwztRight = false; - //差分异常上报 + //差分异常上报 break; } }