diff --git a/entry/src/main/ets/model/Worker.ets b/entry/src/main/ets/model/Worker.ets index 3b34d3c..1386300 100644 --- a/entry/src/main/ets/model/Worker.ets +++ b/entry/src/main/ets/model/Worker.ets @@ -31,6 +31,7 @@ export enum WorkerBackMessageType { export interface LogWorkerMessage { type: WorkerMessageType; data?: string; + studentDirName?: string } //枚举 @@ -45,7 +46,8 @@ export enum WorkerMessageType { ProcessDataInit = 'processDataInit', // 打开过程数据文件 OpenProcessDataFile = 'openProcessDataFile', - + // 初始化考试过程 + ExamProcessInit = 'examProcessInit' } export interface LogPathType { diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 1c4ae6d..2d01f4f 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -256,118 +256,120 @@ export default class Judge { private isEndTip: boolean = false; private deductedPopShowTimer: number = 0; // 校验考试是否结束 - checkExamIsEnd = - async (isManual?: boolean) => { - const judgeUI = this.judgeUI - const avPlayer = this.avPlayer - const isExamEnd = this.isExamEnd - const isEndTip = this.isEndTip - const isAllProjectsEnd = judgeUI.isAllProjectsEnd - const examSubject = judgeUI.examSubject - const singlePlay = judgeUI.singlePlay - const totalScore = Number(judgeUI.totalScore) - const judgeConfigObj = judgeUI.judgeConfigObj - const examMileage = Number(judgeUI.examMileage) - const passingScore = Number(judgeUI.examMileage) - const jl = judgeUI.jl + checkExamIsEnd = async (isManual?: boolean) => { + dConsole.log(JudgeTag, "校验考试是否结束") + const judgeUI = this.judgeUI + const avPlayer = this.avPlayer + const isExamEnd = this.isExamEnd + const isEndTip = this.isEndTip + const isAllProjectsEnd = judgeUI.isAllProjectsEnd + const examSubject = judgeUI.examSubject + const singlePlay = judgeUI.singlePlay + const totalScore = Number(judgeUI.totalScore) + const judgeConfigObj = judgeUI.judgeConfigObj + const examMileage = Number(judgeUI.examMileage) + const passingScore = Number(judgeUI.examMileage) + const jl = judgeUI.jl - if (isExamEnd) { - return - } - //及格分 - let passingGrade = passingScore - if (isManual) { - // 考试不合格 - await examJudgeEndExam() - this.isExamEnd = true - this.isManual = true - } else { - const param302: number = Reflect.get(judgeConfigObj, '302') - const param342: number = Reflect.get(judgeConfigObj, '342') - const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(','); + if (isExamEnd) { - //单机模式 - if (singlePlay) { - dConsole.info(JudgeTag + ' 单机模式结束 => ', isAllProjectsEnd) - if (isAllProjectsEnd && jl >= examMileage) { - //成绩合格 - if (totalScore >= passingGrade && !isEndTip) { - if (examSubject == '3' && (param342 == 0 || param342 == 2) && - (param302 != 6 && param302 != 7 && param302 != 8)) { - if (param512[7] != 0) { - clearTimeout(this.deductedPopShowTimer) - avPlayer?.playAudio(['voice/综合评判.mp3']) - this.judgeUI.isDeductedPopShow = true - this.judgeUI.defaultTabIndex = 1 - this.isEndTip = true - return - } - } else { - await examJudgeEndExam() - this.isExamEnd = true + return + } + //及格分 + let passingGrade = passingScore + if (isManual) { + // 考试不合格 + await examJudgeEndExam() + this.isExamEnd = true + this.isManual = true + } else { + const param302: number = Reflect.get(judgeConfigObj, '302') + const param342: number = Reflect.get(judgeConfigObj, '342') + const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(','); + + //单机模式 + if (singlePlay) { + dConsole.info(JudgeTag + ' 单机模式结束 => ', isAllProjectsEnd) + if (isAllProjectsEnd && jl >= examMileage) { + //成绩合格 + if (totalScore >= passingGrade && !isEndTip) { + if (examSubject == '3' && (param342 == 0 || param342 == 2) && + (param302 != 6 && param302 != 7 && param302 != 8)) { + if (param512[7] != 0) { + clearTimeout(this.deductedPopShowTimer) + avPlayer?.playAudio(['voice/综合评判.mp3']) + this.judgeUI.isDeductedPopShow = true + this.judgeUI.defaultTabIndex = 1 + this.isEndTip = true return } } else { - if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) { - await examJudgeEndExam() - this.isExamEnd = true - return - } - } - await examJudgeEndExam() - this.isExamEnd = true - } - } else { - //成绩不合格 - if (totalScore < passingGrade) { - //科目三不合格报靠边停车 - if (examSubject == '3' && param302 == 1) { - avPlayer?.playAudio([`voice/考试结束.mp3`]); + await examJudgeEndExam() + this.isExamEnd = true return } + } else { + if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) { + await examJudgeEndExam() + this.isExamEnd = true + return + } + } + await examJudgeEndExam() + this.isExamEnd = true + } + } else { + + //成绩不合格 + if (totalScore < passingGrade) { + //科目三不合格报靠边停车 + if (examSubject == '3' && param302 == 1) { + avPlayer?.playAudio([`voice/考试结束.mp3`]); + return + } + await examJudgeEndExam() + this.isExamEnd = true + return + } + + //成绩合格 + if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { + if (examSubject == '2') { await examJudgeEndExam() this.isExamEnd = true return } - //成绩合格 - if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { - if (examSubject == '2') { - await examJudgeEndExam() - this.isExamEnd = true - return - } + //考试里程判断 + if (examSubject == '3' && jl < examMileage) { + return + } - //考试里程判断 - if (examSubject == '3' && jl < examMileage) { - return - } + //考试合格自动退出 + if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) { + await examJudgeEndExam() + this.isExamEnd = true + return + } - //考试合格自动退出 - if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) { - await examJudgeEndExam() - this.isExamEnd = true - return - } - - if (examSubject == '3' && (param342 == 0 || param342 == 2) && - (param302 != 6 && param302 != 7 && param302 != 8)) { - if (param512[7] != 0) { - clearTimeout(this.deductedPopShowTimer) - this.judgeUI.isDeductedPopShow = false - avPlayer?.playAudio(['voice/综合评判.mp3']) - this.judgeUI.isDeductedPopShow = true - this.judgeUI.defaultTabIndex = 1 - this.isEndTip = true - } - } else { - await examJudgeEndExam() - this.isExamEnd = true + if (examSubject == '3' && (param342 == 0 || param342 == 2) && + (param302 != 6 && param302 != 7 && param302 != 8)) { + if (param512[7] != 0) { + clearTimeout(this.deductedPopShowTimer) + this.judgeUI.isDeductedPopShow = false + avPlayer?.playAudio(['voice/综合评判.mp3']) + this.judgeUI.isDeductedPopShow = true + this.judgeUI.defaultTabIndex = 1 + this.isEndTip = true } + } else { + await examJudgeEndExam() + this.isExamEnd = true } } } } + } private ksjs?: JudgeKSJS private kfArr?: MarkRule[] //所有的科目考试项目(大车&小车) @@ -1059,162 +1061,161 @@ export default class Judge { } } // 更改考试状态 - goVoiceAnnounce = - async (event: number, xmdm: number, kf: MarkRule[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => { + goVoiceAnnounce = async (event: number, xmdm: number, kf: MarkRule[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => { - const beginProject = this.beginProject - const pointsDedute = this.pointsDedute - const endProject = this.endProject - const avPlayer = this.avPlayer - const uploadProgressPhoto = this.uploadProgressPhoto - const judgeTask = this.judgeTask - const handEndExam = this.handEndExam - const judgeUI = this.judgeUI - const checkExamIsEnd = this.checkExamIsEnd - const checkProjectIsStart = this.checkProjectIsStart - const lane = this.lane - const closeAllFiles = this.closeAllFiles + const beginProject = this.beginProject + const pointsDedute = this.pointsDedute + const endProject = this.endProject + const avPlayer = this.avPlayer + const uploadProgressPhoto = this.uploadProgressPhoto + const judgeTask = this.judgeTask + const handEndExam = this.handEndExam + const judgeUI = this.judgeUI + const checkExamIsEnd = this.checkExamIsEnd + const checkProjectIsStart = this.checkProjectIsStart + const lane = this.lane + const closeAllFiles = this.closeAllFiles - const projectsObj: object = judgeUI.projectsObj - const judgeConfigObj: object = judgeUI.judgeConfigObj - const examSubject = judgeUI.examSubject - const jl = judgeUI.jl - const isAllProjectsEnd = judgeUI.isAllProjectsEnd + const projectsObj: object = judgeUI.projectsObj + const judgeConfigObj: object = judgeUI.judgeConfigObj + const examSubject = judgeUI.examSubject + const jl = judgeUI.jl + const isAllProjectsEnd = judgeUI.isAllProjectsEnd - const kfLen = kf.length; - //不报语音的项目列表 - // const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') - // const param611 = judgeConfigObj['611'] || ''; - // const [f, s] = param611.split('/') - switch (event) { - // 项目开始 - case 1: - const param512: JudgeConfigObj = (Reflect.get(judgeConfigObj, '512') || '').split(','); - 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) - // } - // } - setTimeout(() => { - if (Reflect.get(param512, 7) != 0) { - clearTimeout(this.deductedPopShowTimer) - this.judgeUI.isDeductedPopShow = true - } - }, 200) - //项目已考不上传监管信息 - if (!isEnd) { - judgeTask.addTask(async () => { - dConsole.info(JudgeTag, `项目开始-${xmdm}-${project.name}`) - await beginProject(xmdm) - }, { - isDelay: true - }) - judgeTask.addTask(async () => { - dConsole.info(JudgeTag, `项目-${xmdm}-上传照片 start`) - await uploadProgressPhoto(xmdm) - }, { - isDelay: true - }) - project.isUpload = true; - Reflect.set(this.judgeUI.projects, xmdm, project) - } - break; - - // 项目结束 - case 2: { - const project: ProjectInfo = Reflect.get(projectsObj, xmdm) - const endCode = project.projectCodeCenter; - const projectIsEnd = project.isEnd; - // const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh) - // if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { - // endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) - // } - const isStart = await this.checkProjectIsStart(xmdm, 1); - if (isStart) { - //项目结束了就不再生成数据 - dConsole.info(JudgeTag + ' projectIsEnd =>', projectIsEnd) - if (!projectIsEnd) { - judgeTask.addTask(async () => { - dConsole.info(JudgeTag, `项目结束-${xmdm}-${project.name}`) - await endProject(xmdm); - this.xmmcSingleCode = '0'; - this.xmmcEndCode = undefined; - }, { - isDelay: true - }) - } - } - if (!this.judgeUI.isProjectIn) { - this.deductedPopShowTimer = setTimeout(() => { - this.judgeUI.isDeductedPopShow = false - }, (Reflect.get(param512!, 5) || 0) * 1000) - } - project.isEnd = true; - Reflect.set(this.judgeUI.projects, xmdm, project) - break; - } - - // 扣分 - case 3: - dConsole.info(JudgeTag, 'surenjun', '扣分开始') - //扣分时实时播报语音(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 || 0)}.mp3`]) - } - const isStart = await checkProjectIsStart(Number(currentKf.xmdm), 2, currentKf); - if (isStart) { - await judgeTask.addTask(async () => { - dConsole.info(JudgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`) - await pointsDedute(Number(currentKf.xmdm), currentKf) - }, { - isDelay: true - }) - } - break; - - // 考车状态 - case 4: - break - - // 考试结束 - case 5: - dConsole.info(JudgeTag, '考试结束') - //关闭录像 - const singlePlay = AppStorage.get('singlePlay') - if (!singlePlay && this.videoData) { - await endRecordVideo(this.videoData) + const kfLen = kf.length; + //不报语音的项目列表 + // const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') + // const param611 = judgeConfigObj['611'] || ''; + // const [f, s] = param611.split('/') + switch (event) { + // 项目开始 + case 1: + const param512: JudgeConfigObj = (Reflect.get(judgeConfigObj, '512') || '').split(','); + 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) + // } + // } + setTimeout(() => { + if (Reflect.get(param512, 7) != 0) { + clearTimeout(this.deductedPopShowTimer) + this.judgeUI.isDeductedPopShow = true } + }, 200) + //项目已考不上传监管信息 + if (!isEnd) { judgeTask.addTask(async () => { - dConsole.info(JudgeTag, '考试结束 start') - AppStorage.setOrCreate('isJudge', false) - await handEndExam() + dConsole.info(JudgeTag, `项目开始-${xmdm}-${project.name}`) + await beginProject(xmdm) + }, { + isDelay: true }) - // TODO待修改 - // clearInterval(globalThis.judgeTimer) - break - default: - break - } - if (event == 2 || event == 3) { - // setTimeout(() => { - // this.judgeUI.kfArrScroller.scrollTo({ - // yOffset: 999999, xOffset: 0 - // }) - // }, 500) - //统计必考项目完成数量 - await this.setCountItems(); - await checkExamIsEnd() + judgeTask.addTask(async () => { + dConsole.info(JudgeTag, `项目-${xmdm}-上传照片 start`) + await uploadProgressPhoto(xmdm) + }, { + isDelay: true + }) + project.isUpload = true; + Reflect.set(this.judgeUI.projects, xmdm, project) + } + break; + + // 项目结束 + case 2: { + const project: ProjectInfo = Reflect.get(projectsObj, xmdm) + const endCode = project.projectCodeCenter; + const projectIsEnd = project.isEnd; + // const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh) + // if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { + // endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) + // } + const isStart = await this.checkProjectIsStart(xmdm, 1); + if (isStart) { + //项目结束了就不再生成数据 + dConsole.info(JudgeTag + ' projectIsEnd =>', projectIsEnd) + if (!projectIsEnd) { + judgeTask.addTask(async () => { + dConsole.info(JudgeTag, `项目结束-${xmdm}-${project.name}`) + await endProject(xmdm); + this.xmmcSingleCode = '0'; + this.xmmcEndCode = undefined; + }, { + isDelay: true + }) + } + } + if (!this.judgeUI.isProjectIn) { + this.deductedPopShowTimer = setTimeout(() => { + this.judgeUI.isDeductedPopShow = false + }, (Reflect.get(param512!, 5) || 0) * 1000) + } + project.isEnd = true; + Reflect.set(this.judgeUI.projects, xmdm, project) + break; } + + // 扣分 + case 3: + dConsole.info(JudgeTag, 'surenjun', '扣分开始') + //扣分时实时播报语音(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 || 0)}.mp3`]) + } + const isStart = await checkProjectIsStart(Number(currentKf.xmdm), 2, currentKf); + if (isStart) { + await judgeTask.addTask(async () => { + dConsole.info(JudgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`) + await pointsDedute(Number(currentKf.xmdm), currentKf) + }, { + isDelay: true + }) + } + break; + + // 考车状态 + case 4: + break + + // 考试结束 + case 5: + dConsole.info(JudgeTag, '考试结束') + //关闭录像 + const singlePlay = AppStorage.get('singlePlay') + if (!singlePlay && this.videoData) { + await endRecordVideo(this.videoData) + } + judgeTask.addTask(async () => { + dConsole.info(JudgeTag, '考试结束 start') + AppStorage.setOrCreate('isJudge', false) + await handEndExam() + }) + // TODO待修改 + // clearInterval(globalThis.judgeTimer) + break + default: + break } + if (event == 2 || event == 3) { + // setTimeout(() => { + // this.judgeUI.kfArrScroller.scrollTo({ + // yOffset: 999999, xOffset: 0 + // }) + // }, 500) + //统计必考项目完成数量 + await this.setCountItems(); + await checkExamIsEnd() + } + } // 考试扣分 pointsDedute = async (ksxm: number, kf: MarkRule) => { const carInfo = AppStorage.get('carInfo')!; @@ -1907,7 +1908,7 @@ export default class Judge { // 2.评判过程回调 await examJudgeSetRealExamCallback(async (strData: string, len: number) => { // 评判回调日志 - // await fileLog?.setExamJudgeCallbackData(strData) + await fileLog?.setExamJudgeCallbackData(strData) dConsole.info(JudgeTag, '评判回调数据', strData) await this.handleRealExam(strData, callBack) }) @@ -1963,7 +1964,6 @@ export default class Judge { } // 处理实时udp里的plc信号 DifferentialAndSignal.onMsg((data: string) => { - dConsole.info(JudgeTag, 'socketTag[PLC.UdpClient]', '收到udp回调数据') const result: WorkerBackMessage = JSON.parse(data) if (result.type === WorkerBackMessageType.ObtainUdpData) { handleUdp(result.data as string) diff --git a/entry/src/main/ets/workers/Log.ets b/entry/src/main/ets/workers/Log.ets index 6b5f228..3569a29 100644 --- a/entry/src/main/ets/workers/Log.ets +++ b/entry/src/main/ets/workers/Log.ets @@ -16,15 +16,18 @@ workerPort.onmessage = (e: MessageEvents) => { let logFileFd: LogFileFd = {} const result: LogWorkerMessage = JSON.parse(e.data); if (result.type === WorkerMessageType.Init) { - Init() + InitLog() } if (result.type === WorkerMessageType.OpenProcessDataFile) { OpenProcessDataFile(logPaths, logFileFd, result.data || "") } + if (result.type === WorkerMessageType.ExamProcessInit && result.studentDirName) { + InitExam(result.studentDirName) + } } -// 初始化 -async function Init() { +// 初始化日志 +async function InitLog() { // /mnt/hmdfs/100/account/device_view/local/files/duolun/logs/2024_10_12 // 创建duolun文件夹 /mnt/hmdfs/100/account/device_view/local/files/duolun const basePath = GlobalConfig.commonFileWriteAddress; @@ -57,6 +60,16 @@ async function Init() { } } +// 初始化学员过程数据目录 +async function InitExam(name: string) { + let date = dayTs().format("YYYY_MM_DD") + const path = `${GlobalConfig.commonFileWriteAddress}/logs/${date}/${name}` + const nameDirIsExit = await IsExit(path) + if (!nameDirIsExit) { + await CreateDir(path); + } +} + function OpenProcessDataFile(logPaths: LogPathType, logFileFd: LogFileFd, name: string) { }