From 7df90207e8375570aeae4e54fbf4ceb472b9e63d Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Tue, 16 Sep 2025 16:46:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/judgeSDK/judge.ts | 785 +++++++++++---------- 1 file changed, 407 insertions(+), 378 deletions(-) diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index d5d99e41..198199b3 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -15,6 +15,7 @@ import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; import UsbService from '../../common/service/usbService'; import { KF, LANE } from '../judgeSDK/api/judgeSDK.d'; import { endRecordVideo, saveStartRecordVideo } from '../../common/service/videoService'; + import { Array2Byte, convertGpsCoord2, @@ -54,7 +55,7 @@ import { examJudgeVersion } from './api/index'; import { getSyncData, upDateTableByArray } from '../../common/service/initable'; -import promptAction from '@ohos.promptAction'; +import { GlobalConfig } from '../../config'; import Want from '@ohos.app.ability.Want'; const judgeTag = 'SURENJUN_JUDGE' @@ -66,7 +67,6 @@ function ifNeedRetry(code: number | string): boolean { } return false } - export default class Judge { // 过程照片拍照 getPhoto = async (empty?: boolean) => { @@ -75,7 +75,7 @@ export default class Judge { if (singlePlay) { return '' } else { - const { filePhoto } = this; + const {filePhoto} = this; const photoBase64 = await filePhoto.getPhoto(); console.info(judgeTag, '拍照完成') return photoBase64 @@ -83,7 +83,7 @@ export default class Judge { } //人工操作项目 public setJudgeItem = async (itemno, type: 1 | 2) => { - const { fileLog } = this; + const {fileLog} = this; await examJudgeArtificialItem(itemno * 1, type); await fileLog.setExamJudgeData({ method: 'examJudgeArtificialItem', @@ -94,7 +94,7 @@ export default class Judge { } //人工扣分 public setJudgeMark = async (itemno, serial, type = 1) => { - const { fileLog } = this + const {fileLog} = this await examJudgeArtificialMark(itemno * 1, serial, type); console.info(judgeTag, `进入人工扣分-${itemno}-${serial}`) await fileLog.setExamJudgeData({ @@ -108,7 +108,7 @@ export default class Judge { } // 断网数据补传 uploadDisConnectData = async () => { - const { isJudgeDisConnect, fileLog, fileUtil } = this; + const {isJudgeDisConnect,fileLog,fileUtil} = this; if (!isJudgeDisConnect) { return } @@ -117,15 +117,15 @@ export default class Judge { const examDataArr = examDataStr.split('\n'); for (let examDataStr of examDataArr) { const examData = JSON.parse(examDataStr) - const code = await writeObjectOut(examData, false); + const code = await writeObjectOut(examData,false); } } //上传无锡所过程数据 uploadProgressData = async () => { - const { judgeUI, fileUtil, fileLog } = this; - const { idCard, startFullTime } = judgeUI + const {judgeUI,fileUtil,fileLog} = this; + const {idCard,startFullTime} = judgeUI const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo + const {carId,examinationRoomId} = carInfo const folderPath = fileLog.folderPath const base64 = new util.Base64(); const time = await getCurrentTime(); @@ -161,25 +161,23 @@ export default class Judge { } //获取科目三的评判初始化配置 getKm3JudgeInitConfig = async () => { - const { judgeUI, getModelData } = this; - const { mapPointArr, mapPointItemArr } = judgeUI; + const {judgeUI,getModelData} = this; + const {mapPointArr,mapPointItemArr} = judgeUI; return { map_point: mapPointArr, map_point_item: mapPointItemArr, //科目三暂时为空 iteminfo: [], - roads: getModelData('km3/Roads.txt'), - sharps: getModelData('km3/Sharps.txt') + roads: getModelData('Roads.txt'), + sharps: getModelData('Sharps.txt') } } // 处理特殊参数配置 handleSEP = async (code: number) => { - const { - judgeUI:{ - judgeConfigObj - }, avPlayer - } = this; - const { examSubject } = globalThis.carInfo; + const {judgeUI:{ + judgeConfigObj + },avPlayer} = this; + const {examSubject} = globalThis.carInfo; switch (code) { //结束考试方式 @@ -198,9 +196,9 @@ export default class Judge { if (xmdm == 20) { return true } - const { judgeTask, beginProject, pointsDedute, uploadProgressPhoto, endProject, checkExamIsEnd, totalScore } = this; - const { projectsObj, passingScore:passingGrade } = this.judgeUI - const { isUpload } = projectsObj[xmdm]; + const {judgeTask,beginProject,pointsDedute,uploadProgressPhoto,endProject,checkExamIsEnd,totalScore} = this; + const {projectsObj,passingScore:passingGrade} = this.judgeUI + const {isUpload} = projectsObj[xmdm]; //如果项目没有开始 console.info('surenjun isUpload=>', isUpload) if (!isUpload) { @@ -244,8 +242,7 @@ export default class Judge { } // 处理udp plc信号 handleUdp = async (msg) => { - console.info('plc信号', msg) - const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this + const {fileLog,getPlcData,usbService,isUdpEnd,isExamEnd,judgeUI} = this const stachArr = msg.split(',') if (stachArr[0] != '#DN_GD' || isUdpEnd) { return @@ -265,20 +262,23 @@ export default class Judge { this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' //TODO 暂时关闭差分检测异常 // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); - if (!isExamEnd) { - await examJudgeRealExam(plcData) - } const udpIndex = globalThis.udpIndex; - let [prevJd, preWd] = [0, 0] if (udpIndex % 5 === 0 && !isUdpEnd) { const judgeUdp = globalThis.judgeUdp const bytes = await this.getMessageHeartbeat(isExamEnd); judgeUdp.send(bytes) } + if (!isExamEnd) { + console.info(judgeTag, 'start examJudgeRealExam') + await examJudgeRealExam(plcData) + console.info(judgeTag, 'end examJudgeRealExam') + } + let [prevJd, preWd] = [0, 0] globalThis.udpIndex += 1 } private fileLog private filePath + private bklx: number = 0 private totalScore: number private prevJd: number = 0 private prevWd: number = 0 @@ -287,7 +287,7 @@ export default class Judge { private modelPath: string private avPlayer private carztStr: string - private rmndg: 0 | 1 + private rmndg: 0 | 1 | 2 private mndgStr: string | undefined // 模拟灯光 setMndg = async (mndgStr: string) => { @@ -317,11 +317,11 @@ export default class Judge { private tempData: any //实时计算gps经纬度距离 handDistance = async () => { - const { jd, wd, hxj, dwzt, jdzt } = this.tempData.gps; + const {jd,wd,hxj,dwzt,jdzt} = this.tempData.gps; const tJD = convertGpsCoord2(jd) const tWD = convertGpsCoord2(wd) - const { prevJd, prevWd } = this - if (prevJd && dwzt == 4 && jdzt == 3) { + const {prevJd,prevWd} = this + if (prevJd && dwzt == 4 && jdzt == 3 && !globalThis.singlePlay) { const distance = await examCalcGpsDistance({ jd1: prevJd, wd1: prevWd, @@ -330,7 +330,7 @@ export default class Judge { h: hxj || 1, }) //@ts-ignore - globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) + // globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) } this.prevJd = tJD; this.prevWd = tWD; @@ -338,7 +338,7 @@ export default class Judge { private performInfo: any private isEndTip: boolean = false; private deductedPopShowTimer: number = 0; - // 校验考试是否结束 + // 校验考试是否结束 checkExamIsEnd = async (isManual?: boolean) => { @@ -392,10 +392,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 } } @@ -470,9 +470,11 @@ export default class Judge { //所有的科目考试项目(大车&小车) private testKmItems: any private plcData: any + //特殊扣分标记 + private specialkf:string = '' // 获取plc数据 getPlcData = async (plc: string) => { - const { fileLog, mndgStr, rmndg } = this; + const {fileLog,mndgStr,rmndg} = this; await fileLog.setPlcProgressData(plc) //plc字符串转化成评判初始化数据 const tempData = await plcStrToJson(plc); @@ -494,12 +496,13 @@ export default class Judge { } // 处理轨迹plc信号 handleTrajectoryUdp = async (strArr) => { - const { fileLog, setJudgeItem, setJudgeMark, endExam } = this; + const {fileLog,setJudgeItem,setJudgeMark,endExam} = this; let num = 2; const judgeTimer = setInterval(async () => { const msgStr = strArr[num]; if (msgStr == '') { console.info(judgeTag, '模拟数据考试结束') + globalThis.windowClass.setWindowSystemBarEnable(['navigation']) clearInterval(judgeTimer) this.checkExamIsEnd(true) return @@ -520,11 +523,14 @@ export default class Judge { if (msg.method === 'examJudgeArtificialMark') { setJudgeItem(msg.itemno, msg.serial) } + msg.sensor.rmndg = this.rmndg + await fileLog.setExamJudgeData(msg) await examJudgeRealExam(msg) + this.rmndg = 0 const bytes = await this.getMessageHeartbeat(); bytes && globalThis.judgeUdp.send(bytes) - }, 200) + }, 1000) globalThis.judgeTimer = judgeTimer; } @@ -536,19 +542,17 @@ export default class Judge { // 调代理接口是否断网了 private isJudgeDisConnect: boolean; // 项目开始接口同步 - beginProject = async (ksxm) => { + beginProject = async (ksxm,xmxh?:string) => { const carInfo = globalThis.carInfo; - const { examSubject, plateNo } = carInfo; - const { judgeUI, fileLog, getSbbm, xmxh, filePath } = this; - const { lsh, idCard, serialNumber, projectsObj, ksdd, kslx, xldm } = judgeUI + const { examSubject,plateNo } = carInfo; + const {judgeUI,fileLog,getSbbm,filePath} = this; + const {lsh,idCard,serialNumber,projectsObj,ksdd,kslx,xldm} = judgeUI const time = await getCurrentTime(); const project = projectsObj[ksxm] - const sbxh = getSbbm(ksxm, xmxh) + const sbxh = getSbbm(ksxm, xmxh || this.xmxh) const data = { //系统类别 接口序列号 接口标识 - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C52', + xtlb: '17', jkxlh: serialNumber, jkid: '17C52', drvexam: { // 考试科目 身份证号码 lsh, @@ -564,7 +568,7 @@ export default class Judge { kssj: time } } - const { code } = await this.sendWriteObjectOut(data, filePath) + const {code} = await this.sendWriteObjectOut(data, filePath) console.info(judgeTag, '项目开始 end') if (code === 2300007) { this.isJudgeDisConnect = true; @@ -572,20 +576,18 @@ export default class Judge { promptWxCode('17C52', code) } // 项目结束接口同步 - endProject = async (ksxm) => { + endProject = async (ksxm,xmxh?:string) => { const carInfo = globalThis.carInfo; const deviceNo = globalThis.deviceNo; - const { examSubject, plateNo, carNo } = carInfo; - const { judgeUI, fileLog, getSbxh, xmxh, getSbbm, filePath } = this; - const { lsh, idCard, serialNumber, projectsObj, cdsbInfoObj, ksdd, kslx, xldm, } = judgeUI + const { examSubject,plateNo,carNo } = carInfo; + const {judgeUI,fileLog,getSbxh,getSbbm,filePath} = this; + const {lsh,idCard,serialNumber,projectsObj,cdsbInfoObj,ksdd,kslx,xldm,} = judgeUI const time = await getCurrentTime(); const project = projectsObj[ksxm] - const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh) + const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh || this.xmxh) const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C55', + xtlb: '17', jkxlh: serialNumber, jkid: '17C55', drvexam: { lsh, kskm: examSubject, @@ -601,98 +603,26 @@ export default class Judge { jssj: time } } - const { code } = await this.sendWriteObjectOut(data, filePath) + const {code} = await this.sendWriteObjectOut(data, filePath) + + //科三 & 432=3 + if(examSubject == 3 && this.judgeUI.judgeConfigObj['432'] == 2){ + this.judgeUI.uploadMileage() + } + if (code === 2300007) { this.isJudgeDisConnect = true; } console.info(judgeTag, '项目结束 end') promptWxCode('17C55', code) } - // 考试过程照片 - uploadProgressPhoto = async (ksxm) => { - const time = await getCurrentTime(); - const { judgeUI, plcData, getPhoto, fileLog, filePath } = this; - const photoBase64 = await getPhoto(); - const carInfo = globalThis.carInfo; - const { examSubject, plateNo, carNo } = carInfo; - const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI; - const { sensor, gps } = plcData - const project = projectsObj[ksxm] - - const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C54', - drvexam: { - lsh, - kskm: examSubject, - ksxm: project.projectCodeCenter, - sfzmhm: idCard, - kchp: encodeURI(plateNo), - zpsj: time, - //@ts-ignore - zp: photoBase64, - cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852), - ksdd: encodeURI(ksdd) - } - }; - const { code } = await this.sendWriteObjectOut(data, filePath); - if (code === 2300007) { - this.isJudgeDisConnect = true - } - promptWxCode('17C54', code) - console.info(judgeTag, '上传照片 end') - } private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] private lane: LANE = { road: '', num: 0, count: 0 } private videoData: any private disConnectNum: number = 0; - - constructor(judgeUI) { - this.serialIndex = 1; - this.judgeUI = judgeUI - //语音播放工具 - this.avPlayer = new VoiceAnnounce(); - //模型工具 - this.fileModel = new FileModel(judgeUI.context); - //文件工具 - this.fileUtil = new FileUtil(judgeUI.context) - this.judgeTask = new JudgeTask() - this.usbService = new UsbService(); - this.filePhoto = new FilePhoto(judgeUI.context); - this.kfArr = judgeUI.kfArr - this.xmmcStr = ''; - this.xmmcCode = ''; - this.xmmcEndCode = undefined; - this.carztStr = ''; - this.testKmItems = {}; - // 考试回放配置 - const { isTrajectoryOpen, modelPath, trajectoryPath } = judgeConfig - this.isTrajectoryOpen = isTrajectoryOpen; - this.modelPath = modelPath; - this.trajectoryPath = trajectoryPath; - - this.isExam = !this.judgeUI.singlePlay; - const { projectsCenterObj, examSubject } = judgeUI; - - (examSubject == 2 ? testKm2Items : testKm3Items).forEach(item => { - const projectCenterObj = projectsCenterObj[item.code] - this.testKmItems[item.code] = item; - //考试项目存在 - this.testKmItems[item.code] = { - code: item.code, - status: projectCenterObj === undefined - ? 0 - : (projectCenterObj.isEnd ? 3 : 1) - } - }) - - console.info(judgeTag + 'testKmItems', JSON.stringify(this.testKmItems)) - this.isExamEnd = false; - } - + //调用监管接口 private externalTransmission: boolean = false // 计算是否启动 private whetherToStart: boolean @@ -748,6 +678,82 @@ export default class Judge { this.disConnectNum = 0 return temp } + // 考试过程照片 + uploadProgressPhoto = async (ksxm) => { + const time = await getCurrentTime(); + const {judgeUI,plcData,getPhoto,fileLog,filePath} = this; + const photoBase64 = await getPhoto(); + const carInfo = globalThis.carInfo; + const { examSubject,plateNo,carNo } = carInfo; + const {lsh,idCard,serialNumber,projectsObj,ksdd,judgeConfigObj} = judgeUI; + const {sensor,gps} = plcData + const project = projectsObj[ksxm] + + const data = { + xtlb: '17', jkxlh: serialNumber, jkid: '17C54', + drvexam: { + lsh, + kskm: examSubject, + ksxm: project.projectCodeCenter, + sfzmhm: idCard, + kchp: encodeURI(plateNo), + zpsj: time, + //@ts-ignore + zp: photoBase64, + cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852), + ksdd: encodeURI(ksdd) + } + }; + const {code} = await this.sendWriteObjectOut(data, filePath); + if (code === 2300007) { + this.isJudgeDisConnect = true + } + promptWxCode('17C54', code) + console.info(judgeTag, '上传照片 end') + } + + constructor(judgeUI) { + this.serialIndex = 1; + this.judgeUI = judgeUI + //语音播放工具 + this.avPlayer = new VoiceAnnounce(); + //模型工具 + this.fileModel = new FileModel(judgeUI.context); + //文件工具 + this.fileUtil = new FileUtil(judgeUI.context) + this.judgeTask = new JudgeTask() + this.usbService = new UsbService(); + this.filePhoto = new FilePhoto(judgeUI.context); + this.kfArr = judgeUI.kfArr + this.xmmcStr = ''; + this.xmmcCode = ''; + this.xmmcEndCode = undefined; + this.carztStr = ''; + this.testKmItems = {}; + // 考试回放配置 + const {isTrajectoryOpen,trajectoryPath} = judgeConfig + this.isTrajectoryOpen = isTrajectoryOpen; + this.modelPath = 'models'; + this.trajectoryPath = trajectoryPath; + + this.isExam = !this.judgeUI.singlePlay; + const {projectsCenterObj,examSubject} = judgeUI; + + (examSubject == 2 ? testKm2Items : testKm3Items).forEach(item => { + const projectCenterObj = projectsCenterObj[item.code] + this.testKmItems[item.code] = item; + //考试项目存在 + this.testKmItems[item.code] = { + code: item.code, + status: projectCenterObj === undefined + ? 0 + : (projectCenterObj.isEnd ? 3 : 1) + } + }) + + console.info(judgeTag + 'testKmItems', JSON.stringify(this.testKmItems)) + this.isExamEnd = false; + } public async onJudgeFn(fn: Function) { await this.judging(fn) @@ -755,35 +761,43 @@ export default class Judge { // 获取评判初始化数据 getJudgeInitData = async () => { - const { getModelData, getKm3JudgeInitConfig } = this + const {getModelData,getKm3JudgeInitConfig,bklx} = this const carInfo = globalThis.carInfo; - const { examSubject, plateNo, carId } = carInfo; + const { examSubject,plateNo,carId } = carInfo; const judgeUI = this.judgeUI - const { projectsObj, itemInfoObj, markRuleListObj, carType, carName, systemparmArr, carinfoArr } = judgeUI + const {projectsObj,itemInfoObj,markRuleListObj,carType,carName,systemparmArr,carinfoArr} = judgeUI const examType = examSubject == 2 ? 'km2' : 'km3' + const fileUtil = new FileUtil(globalThis.context) + const ipConfigStr = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); + const ipConfig = JSON.parse(ipConfigStr) let allitems = []; if (examSubject == 2) { allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { const cdsb = itemInfoObj[cdsbKey]; - const { xmdm, xmxh, modelKey } = cdsb - return { - xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`) + const {xmdm,xmxh,modelKey} = cdsb + const modelVal= getModelData(`${modelKey}.txt`) + if(modelVal){ + return { + xmdm, xmxh, model: modelVal + } + }else{ + return undefined } - }) + }).filter(item => item !== undefined) } //获取版本号 const sdkver = await examJudgeVersion(); const initInfo = { sdkver, - appver: judgeConfig.version, + appver: globalThis.version, kskm: examSubject * 1, kchp: plateNo, kchm: carId * 1, kscx: carType, cxcode: '1', name: carName, - carmodel: getModelData(`${examType}/${carType}.txt`), + carmodel: getModelData(`${carType}.txt`), allitems, iteminfo: [], systemparm: systemparmArr, @@ -792,6 +806,8 @@ export default class Judge { itemInfoObj, carlist: judgeUI.carlist, carinfo: carinfoArr, + //板卡类型 + bklx, }; let km3Config = {} @@ -808,13 +824,12 @@ export default class Judge { // 获取开始考试数据 getJudgeBeginData = async () => { - const { code, name:examinerName } = globalThis.examinerInfo; + const {code,name:examinerName} = globalThis.examinerInfo; let currentParams: any = router.getParams(); - const { sczb, kfdm } = currentParams; - const { isExam } = this; + const {sczb,kfdm} = currentParams; + const {isExam} = this; const judgeUI = this.judgeUI - const { projects, carType, kssycs, isDdxk, ddxkTime, projectsCenterObj, ddxkKsxmArr, ddxkKfArr, passingScore } = - judgeUI; + const {projects,carType,kssycs,isDdxk,ddxkTime,projectsCenterObj,ddxkKsxmArr,ddxkKfArr,passingScore} = judgeUI; const beginInfo = { kgid: '012', kgxm: decodeURI(examinerName || ''), @@ -852,16 +867,15 @@ export default class Judge { xmdm: xmdm * 1, kfdm } })) : [], - //TODO 已考里程待修改 - yklc: 0, + yklc: judgeUI.yklc, special: [], - //TODO 科目三参数临时写死 sczb: (sczb === undefined || sczb == 0) ? 0 : 1, sczbkf: kfdm, dmndg: false, mfxx: false, mfxxn: false, - zeng: false + //科目三特殊扣分项 + specialkf:judgeUI.specialkf, } console.info(judgeTag, '5.获取开始考试数据完成') return beginInfo @@ -870,14 +884,14 @@ export default class Judge { //处理评判过程回调 handleRealExam = async (strData, callBack) => { let examData: EXAMDATA = JSON.parse(strData); - const { getDqxmStr, getKfStr, goJudgeVoice, setMndg, avPlayer, fileLog, judgeUI } = this; - const { carzt, xmks, kf, event, xmjs, xmqx, ksjs, sound, mndg, lane, precast, nongps } = examData + const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,avPlayer,fileLog,judgeUI} = this; + const {carzt,xmks,kf,event,xmjs,xmqx,ksjs,sound,mndg,lane,precast,nongps} = examData const param512 = (judgeUI.judgeConfigObj['512'] || '').split(','); //获取项目结束、项目开始代码 const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh; const isManualProjectIn = this.artSubject3ProjectsCodesArr.includes(xmdm); - const { examSubject, projects, judgeConfigObj } = this.judgeUI; + const {examSubject,projects,judgeConfigObj} = this.judgeUI; const param611 = judgeConfigObj['611'] || ''; switch (event) { //项目开始 @@ -966,10 +980,10 @@ export default class Judge { //项目取消 case 6: { console.info(judgeTag, '项目取消'); - const { examSubject } = this.judgeUI + const {examSubject} = this.judgeUI const xmdm = xmqx.xmdm; const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); + // const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); // avPlayer.playAudio([`voice/${voiceCode}.mp3`],true) this.judgeUI.projectsObj[xmdm].type = '1'; this.testKmItems[xmmcCode].status = '1'; @@ -996,7 +1010,7 @@ export default class Judge { case 10: { const param611 = judgeConfigObj['611'] || ''; const [f, s] = param611.split('/') - const { xmdm, xmxh } = precast; + const {xmdm,xmxh} = precast; const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; // if(examSubject == 2 && ((xmdm == 0 && f == 1) || (xmdm == 1 && s == 1) || xmdm == 3)){ @@ -1015,7 +1029,7 @@ export default class Judge { //差分事件 case 11: { - const { type } = nongps + const {type} = nongps this.checkDwzt(type) } default: @@ -1023,7 +1037,7 @@ export default class Judge { } - const { xmmcStr, carztStr, kfArr } = this; + const {xmmcStr,carztStr,kfArr} = this; await callBack({ //项目名称 考车状态 扣分arr @@ -1056,7 +1070,7 @@ export default class Judge { closeAllFiles } = this; - const { projectsObj, judgeConfigObj, examSubject, examMileage, jl, isAllProjectsEnd } = judgeUI; + const {projectsObj,judgeConfigObj,examSubject,examMileage,jl,isAllProjectsEnd} = judgeUI; const kfLen = kf.length; //不报语音的项目列表 const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') @@ -1086,7 +1100,7 @@ export default class Judge { if (!isEnd) { judgeTask.addTask(async () => { console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`) - await beginProject(xmdm) + await beginProject(xmdm,xmxh) }, { isDelay: true }) @@ -1115,7 +1129,7 @@ export default class Judge { if (!projectIsEnd) { judgeTask.addTask(async () => { console.info(judgeTag, `项目结束-${xmdm}-${projectsObj[xmdm].name}`) - await endProject(xmdm); + await endProject(xmdm,xmxh) this.xmmcSingleCode = 0; this.xmmcEndCode = undefined; }, { @@ -1137,8 +1151,7 @@ export default class Judge { console.info('surenjun', '扣分开始') //扣分时实时播报语音(0-否+1-是) const currentKf = kf[kfLen -1]; - if (judgeConfig.kfVoiceOpen || (examSubject == 2 && judgeConfigObj['618'] == '1') || - (examSubject == 3 && judgeConfigObj['418'] == '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`]) } const isStart = await checkProjectIsStart(currentKf.xmdm, 2, currentKf); @@ -1189,13 +1202,13 @@ export default class Judge { pointsDedute = async (ksxm, kf) => { const carInfo = globalThis.carInfo; const deviceNo = globalThis.deviceNo; - const { examSubject, plateNo, carNo } = carInfo; - const { judgeUI, getProjectInfo, fileLog, xmmcSingleCode, xmmcEndCode, filePath } = this; - const { lsh, idCard, serialNumber, ksdd, projectsObj } = judgeUI + const { examSubject,plateNo,carNo } = carInfo; + const {judgeUI,getProjectInfo,fileLog,xmmcSingleCode,xmmcEndCode,filePath} = this; + const {lsh,idCard,serialNumber,ksdd,projectsObj} = judgeUI const time = await getCurrentTime(); const project = getProjectInfo(ksxm); - //科目三夜间行驶.模拟灯光、上车准备出现通用评判,ksxm为当前进行的项目 - const checkProjects = ['17', '41', '1']; + //科目三夜间行驶.模拟灯光、上车准备出现非本项目的扣分,ksxm需转换为为当前进行的项目 + const checkProjects = ['1', '41', '17']; //获取正在进行的项目 const inProjects = Reflect.ownKeys(projectsObj).filter(projectKey => projectsObj[projectKey].type == 2); @@ -1205,11 +1218,10 @@ export default class Judge { commonKsxm = projectCode } }) - + console.info(judgeTag, 'commonKsxm=>' + commonKsxm) + console.info(judgeTag, 'project=>' + project) const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C53', + xtlb: '17', jkxlh: serialNumber, jkid: '17C53', drvexam: { lsh, kskm: examSubject, @@ -1217,7 +1229,7 @@ export default class Judge { ? (commonKsxm ? (projectsObj[commonKsxm].projectCodeCenter) : (examSubject == 3 ? 30000 : (xmmcEndCode == undefined ? 10000 : xmmcEndCode))) - : project.projectCodeCenter, + : (projectsObj[commonKsxm]?.projectCodeCenter || project.projectCodeCenter), kfxm: kf.markcatalog, kfxmmx: `${ksxm},${kf.markserial}`, sfzmhm: idCard, @@ -1229,8 +1241,7 @@ export default class Judge { } } console.info(judgeTag + 'ksxm=>', data.drvexam.ksxm) - - const { code } = await this.sendWriteObjectOut(data, filePath); + const {code} = await this.sendWriteObjectOut(data, filePath); if (code == 2300007) { this.isJudgeDisConnect = true } @@ -1240,8 +1251,8 @@ export default class Judge { // 评判语音提示 goJudgeVoice = async (sound: SOUND) => { - const { avPlayer, fileLog } = this; - const { xmdm, code, type } = sound; + const {avPlayer,fileLog} = this; + const {xmdm,code,type} = sound; console.info('surenjun code=>', JSON.stringify(code)) //判断是不是模拟灯光语音 if (type == 1) { @@ -1258,10 +1269,14 @@ export default class Judge { }) } else { //收到综合评判语音时,显示综合评判弹窗 - if (code[0] == 'zhpp') { + if(code[0] == 'zhpp'){ + const param512 = (this.judgeUI.judgeConfigObj['512'] || '').split(','); + this.judgeUI.isDeductedPopShow = false clearTimeout(this.deductedPopShowTimer) - this.judgeUI.isDeductedPopShow = true - this.judgeUI.defaultTabIndex = 1 + if(param512[7] != 0){ + this.judgeUI.isDeductedPopShow = true + this.judgeUI.defaultTabIndex = 1 + } this.isEndTip = true } avPlayer.playAudio([`voice/${code[0]}.mp3`]) @@ -1273,19 +1288,20 @@ export default class Judge { this.judgeUI.loadingPopupVisible = true; this.judgeUI.endPopupVisible = false; this.judgeUI.isDeductedPopShow = false; - const { qjjl, dcjl } = ksjs - const { judgeUI, endExam, handleSEP, kfArr, avPlayer, judgeTask, isManual, closeAllFiles } = this; - const { judgeConfigObj, examSubject, isAllProjectsEnd, totalScore, passingScore } = judgeUI; + const {qjjl,dcjl} = ksjs + const {judgeUI,endExam,handleSEP,kfArr,avPlayer,judgeTask,isManual,closeAllFiles} = this; + const {judgeConfigObj,examSubject,isAllProjectsEnd,totalScore,passingScore} = judgeUI; //计算考试分数 // this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0; const singlePlay = globalThis.singlePlay const param302 = judgeConfigObj['302']; + // globalThis.windowClass.setWindowSystemBarEnable(['navigation']) //自动退出待验证并且不合格 - if (!isManual && examSubject == 3 && (param302 == 1 || (singlePlay && param302 == 2)) && - totalScore < passingScore) { + if (!isManual && examSubject == 3 && (param302 == 1 || (singlePlay && param302 == 2)) && totalScore < passingScore) { avPlayer.playAudio([`voice/考试结束.mp3`]) } + //联网模式下:项目没有做完、当前分数大于及格分;手动结束直接退出 if (!singlePlay && isManual && !isAllProjectsEnd && totalScore >= passingScore) { avPlayer.playAudio(['voice/empty.mp3'], true, () => { @@ -1295,18 +1311,7 @@ export default class Judge { }) return } - if (examSubject == 3) { - const param302 = judgeConfigObj['302']; - if (totalScore < passingScore) { - //考试不合格;考试模式,自动退出; - if (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8) { - } - } else { - //考试合格 - } - } - await handleSEP(306); avPlayer.playAudio(['voice/exam_waiting.mp3'], globalThis.singlePlay, async () => { try { if (!singlePlay) { @@ -1317,6 +1322,7 @@ export default class Judge { console.info(judgeTag, JSON.stringify(e)) } await endExam() + }); } @@ -1325,147 +1331,137 @@ export default class Judge { public endExam = async (isManual?: Boolean) => { const carInfo = globalThis.carInfo; const singlePlay = globalThis.singlePlay - const { examSubject, plateNo } = carInfo; + const { examSubject ,plateNo} = carInfo; const { judgeUI, ksjs, getPhoto, + uploadProgressData, + uploadDisConnectData, avPlayer, kfArr, + judgeTask, filePath, closeAllFiles } = this; - const { lsh, idCard, serialNumber, kssycs, totalScore, judgeConfigObj, isAllProjectsEnd, passingScore } = judgeUI + const {lsh,idCard,serialNumber,kssycs,totalScore,judgeConfigObj,isAllProjectsEnd,passingScore} = judgeUI //TODO 断网考试结束补传 // await uploadDisConnectData(); - 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(';'), - } + 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 = '当前的考试过程信息监管审核未通过,程序将退出!' - } - this.isUdpEnd = true; - closeAllFiles() - this.judgeUI.loadingPopupVisible = false; - return + if (code == 2300028 || code == 2300007) { + this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' } - 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/qualified.mp3': - currentKssycs = 0; - break; - } + 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 } - 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 { + switch (voiceURL) { + case 'voice/unqualified_one.wav': + currentKssycs = 0; + break; + + case 'voice/unqualified_two.wav': + currentKssycs = 1; + break; + + case 'voice/qualified.mp3': + currentKssycs = 0; + break; + } + } + 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 } - 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; - - } + } 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; - const USER = await getSyncData('USER'); - await upDateTableByArray('USER', [{ - ...USER[0], - kssycs: currentKssycs - }]) + case 'voice/exam_no_pass.mp3': + currentKssycs = 1; + break; + + case 'voice/exam_pass.mp3': + currentKssycs = 0; + break; - 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) { - 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 { + } + + 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) { avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; closeAllFiles() @@ -1473,27 +1469,28 @@ export default class Judge { }) 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) { - promptAction.showToast({ - message: "考试结束异常,请尝试重新结束", - duration: 3000 + 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) }) - judgeUI.loadingPopupVisible = false } } @@ -1520,7 +1517,7 @@ export default class Judge { // 消息心跳发送 getMessageHeartbeat = async (isEnd?: Boolean) => { const carInfo = globalThis.carInfo; - const { examSubject, plateNo, ksyh } = carInfo; + const { examSubject,plateNo,ksyh } = carInfo; const { judgeUI, isExam, @@ -1537,19 +1534,17 @@ export default class Judge { fileLog, } = this; const singlePlay = globalThis.singlePlay - const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI; - const { - fourInOneScreen:{ - gpsDigit - } - } = judgeConfig + const {lsh,startHourTime,totalScore,examTime,judgeConfigObj} = judgeUI; + const {fourInOneScreen:{ + gpsDigit + }} = judgeConfig const examType = examSubject == 2 ? 2 : 3 - const { sensor, gps } = tempData; + const {sensor,gps} = tempData; if (tempData.sensor === undefined) { return } - const { zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, ygq, cs, fdjzs, dw } = sensor - const { jd, wd, hxj, fyj, hbg, sd } = gps; + const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs,dw} = sensor + const {jd,wd, hxj, fyj, hbg,sd} = gps; //过滤错误数据 if (jd == 0) { @@ -1557,16 +1552,17 @@ export default class Judge { } const translateProject = getTranslateProject(); const sbxh = getSbxh(xmdm, xmxh) - const { carzt, dcjl, qjjl, dxjl, bxjl } = performInfo || {}; + const {carzt,dcjl,qjjl,dxjl,bxjl} = performInfo || {}; const asclshArr = stringToASC( - fillZero((singlePlay ? (examSubject == 2 ? '0000000000000' : '1111111111111') : lsh) || 0, 13) + fillZero(( + singlePlay ? + (examSubject == 2 ? '0000000000000' : '0000000000000') : lsh) || 0, 13) ); //13不足要补0 const ascksyhArr = stringToASC(fillZero(ksyh || 0, 13)) const ascsbxhArr = stringToASC(sbxh) const translateSignals = getTranslateSignals( - [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw)) - .concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0]) + [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw)).concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0]) ) //@ts-ignore const translateJd = convertGpsCoord2(wd).toFixed(gpsDigit) * Math.pow(10, gpsDigit); @@ -1594,8 +1590,7 @@ export default class Judge { translateSignals, //速度 发动机转速 GPS纬度 GPS经度 主天线位置 //@ts-ignore - string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8), - string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8), + string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8), string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8), //GPS东向距离 string2Bytes(dxjl < 0 ? (dxjl + 4294967296) : dxjl, 4 * 8), //GPS北向距离 @@ -1642,8 +1637,8 @@ export default class Judge { //获取场地序号 getSbxh = (ksxm, xmxh) => { - const { judgeUI } = this; - const { cdsbInfoObj, projectsObj } = judgeUI; + const {judgeUI} = this; + const {cdsbInfoObj,projectsObj} = judgeUI; const project = projectsObj[ksxm] if (project == 3) { return '0000000000' @@ -1659,8 +1654,8 @@ export default class Judge { } getSbbm = (ksxm, xmxh) => { - const { judgeUI } = this; - const { cdsbInfoObj, projectsObj, examSubject } = judgeUI; + const {judgeUI} = this; + const {cdsbInfoObj,projectsObj,examSubject} = judgeUI; const project = projectsObj[ksxm] //科目三不需要 if (examSubject == 3) { @@ -1677,7 +1672,7 @@ export default class Judge { // 中心所有项目转换 getTranslateProject = () => { - const { examSubject } = this.judgeUI; + const {examSubject} = this.judgeUI; const tempItems = (examSubject == 2 ? testKm2Items : testKm3Items).map(item => { const current = this.testKmItems[item.code]; return { @@ -1714,23 +1709,22 @@ export default class Judge { // 获取模型数据 getModelData = (modelName) => { - const modelPath = this.modelPath const fileModel = this.fileModel; - const modelData = fileModel.getModelContent(modelPath, modelName); + const modelData = fileModel.getModelContent('models', modelName); return modelData } // 统计必考项目、所有项目、已考数量 setCountItems = async () => { const carInfo = globalThis.carInfo; - const { examSubject } = carInfo; - const { projectsObj } = this.judgeUI; + const { examSubject} = carInfo; + const {projectsObj} = this.judgeUI; //必考项目数量 必考项目已考数量 let projectNum = 0, endProjectsNum = 0; // 所有考试项目数量 项目已考项目数量 let allProjectNum = 0, allEndProjectsNum = 0; Reflect.ownKeys(projectsObj).forEach(projectKey => { - const { type, isRequired } = projectsObj[projectKey]; + const {type,isRequired} = projectsObj[projectKey]; allProjectNum += 1; if (type == 3 || type == 4) { allEndProjectsNum += 1; @@ -1754,8 +1748,8 @@ export default class Judge { // 检测差分状态 checkDwzt = async (type) => { - const { avPlayer } = this; - const judgeConfig = this.judgeUI.judgeConfig; + const {avPlayer} = this; + const config499 = this.judgeUI.judgeConfigObj['499']; switch (type) { case 0: this.judgeUI.isDwztRight = true; @@ -1763,10 +1757,17 @@ export default class Judge { case 1: this.judgeUI.dwztErrorVisible = true; + clearInterval(this.judgeUI.timer); + clearInterval(globalThis.judgeTimer) avPlayer.playAudio([`voice/差分状态异常.mp3`], true) setTimeout(() => { - router.back() - }, 3000) + try { + this.checkExamIsEnd(true); + } catch (e) { + this.closeAllFiles() + router.back() + } + }, config499 * 1000) break; case 2: @@ -1793,14 +1794,20 @@ export default class Judge { //开始评判 private async judging(callBack: Function) { - const { judgeUI } = this; - const { name, lsh, idCard, kssycs, manualMarkRules } = judgeUI; + const {judgeUI} = this; + const { name, lsh, idCard,kssycs,markRules} = judgeUI; const fileLog = new FileLog(judgeUI.context); const filePath = await fileLog.initFileLogo({ name, lsh, idCard }); + + const ipFileUtil = new FileUtil(globalThis.context) + const ipConfigStr = await ipFileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); + const ipConfig = JSON.parse(ipConfigStr) + this.fileLog = fileLog; this.filePath = filePath; + this.bklx = Number(ipConfig.cardType) const { getJudgeBeginData, @@ -1845,6 +1852,7 @@ export default class Judge { this.handleRealExam(strData, callBack) }) + await examJudgeSetPerformCallback(async (info) => { console.info('评判实时数据', info) const performInfo = JSON.parse(info) @@ -1856,6 +1864,11 @@ export default class Judge { this.judgeUI.jl = jl //TODO 待优化 跨组件传值不生效 globalThis.laneData = performInfo.lane; + //特殊扣分标记上传中心 + if(performInfo.specialkf !== this.specialkf){ + this.judgeUI.uploadMileage(performInfo.specialkf) + this.specialkf = performInfo.specialkf + } }) // 3.开始考试 @@ -1872,8 +1885,8 @@ export default class Judge { if (!globalThis.singlePlay) { this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`) } - - const { examSubject, projectsObj } = this.judgeUI + globalThis.statue = 4 + const {examSubject,projectsObj} = this.judgeUI // if(examSubject == 3){ // //不做模拟灯光,需要做上车准备 =>(请上车准备) // if(projectsObj[41]?.type == 3 && projectsObj[1]?.type != 3){ @@ -1901,7 +1914,8 @@ export default class Judge { handDistance(); } }); - + //页面逻辑处理完成 + this.judgeUI.isInitSuccess = true; // this.checkExamIsEnd() //监听远程结束考试 @@ -1909,18 +1923,33 @@ export default class Judge { this.checkExamIsEnd(true); }) - console.info(judgeTag, JSON.stringify(manualMarkRules)) + console.info(judgeTag, JSON.stringify(markRules)) + //监听远程扣分 globalThis.udpEvent.onKfExam(async (content) => { + //为1时,所有扣分项均可远程扣分;其它,只能扣 MARKSERIAL 大于 99 的扣分项 + const config810 = this.judgeUI.judgeConfigObj['810']; console.info('评判收到远程扣分项目内容' + JSON.stringify(content)) - const { kfxh, directives } = content.data; + const { kfxh , directives } = content.data; console.info(judgeTag, '评判收到远程扣分项目内容,扣分序号:' + `kfxh=>${kfxh}; directives=>${directives}`) + //根据扣分序号找扣分代码 - const currentKf = manualMarkRules.filter(mark => mark.kfxh == kfxh)[0]; + const currentKf = markRules.filter(mark => ( + mark.kfxh == kfxh && (config810 == 1 || mark.markserial > 99) + ))[0]; + console.info(judgeTag, '扣分项目:' + JSON.stringify(currentKf)) this.setJudgeMark(currentKf.itemno, currentKf.markserial, 2); globalThis.judgeUdp.confirmKf(directives, 1) }) + + //监听远程终止考试 + globalThis.udpEvent.onStopExam(async () => { + const config392 = (this.judgeUI.judgeConfigObj['392'] || '20,81').split(','); + console.info(judgeTag, '开始远程终止考试扣分') + this.setJudgeMark(config392[0]*1, config392[1], 2); + }) + this.checkExamIsEnd(); }