From 55318d74e13eaff1b75123290302b03b0bac7572 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Fri, 10 Oct 2025 15:16:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=80=83=E8=AF=95=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-profile.json5 | 4 +- entry/src/main/ets/config/LogEnum.ets | 4 + .../main/ets/pages/Judge/JudgeBusiness.ets | 2 +- entry/src/main/ets/pages/Judge/JudgeIng.ets | 267 +++++++++++++++++- entry/src/main/ets/pages/UserInfo.ets | 3 +- entry/src/main/ets/pages/judgeSDK/judge.ets | 5 +- .../judgeSDK/utils/voiceAnnouncements.ets | 2 +- 7 files changed, 275 insertions(+), 12 deletions(-) diff --git a/build-profile.json5 b/build-profile.json5 index 6585cba..66535e1 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,9 +5,9 @@ "name": "default", "material": { "certpath": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.cer", - "storePassword": "0000001BC5B0497609513207A9433B5B0EF8028AB62F6127F2A98ED2502AD0EA5105DE90FBAACCF2A667D5", + "storePassword": "0000001BF9AB68E8C3E0439D2AA8D641FD06550209928E9CB41AFB9E4D799D516B7D7DB8B1863601225968", "keyAlias": "debugKey", - "keyPassword": "0000001B3FE45EBE64E6D2BB019005840285C3EF734D55048F500E5FC51002B110E2BBFE74F4A0B5072E4E", + "keyPassword": "0000001B4363BBA79693F55689ED8AD636125B8928CFC30F51866D1190ABC6372B58D7025E2650A53AFD2B", "profile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p7b", "signAlg": "SHA256withECDSA", "storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/default_car_next_xIuD6UMCLxZgyeiH-w2XdDck6DewIfdHAvOk_FUbNZo=.p12" diff --git a/entry/src/main/ets/config/LogEnum.ets b/entry/src/main/ets/config/LogEnum.ets index 31d64e5..e35fe3c 100644 --- a/entry/src/main/ets/config/LogEnum.ets +++ b/entry/src/main/ets/config/LogEnum.ets @@ -77,3 +77,7 @@ export const ProcessDataTag = '[ProcessData]'; // 日志 export const LogTag = '[LogWorker]'; + +// 开始考试,结束考试标志 +export const StartEndExamTag = '[StartEndExam]'; + diff --git a/entry/src/main/ets/pages/Judge/JudgeBusiness.ets b/entry/src/main/ets/pages/Judge/JudgeBusiness.ets index d463dda..a8e9869 100644 --- a/entry/src/main/ets/pages/Judge/JudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/JudgeBusiness.ets @@ -56,6 +56,7 @@ export default class JudgeBusiness { public carztStr: string public ksjs?: JudgeKSJS public plcData?: PLCType + public totalScore: number = -1 private judgeUI: JudgeUI private tempData?: PLCType // 是否发送udp @@ -160,7 +161,6 @@ export default class JudgeBusiness { if (!this.isExamEnd) { await examJudgeRealExam(this.plcData) } - } } diff --git a/entry/src/main/ets/pages/Judge/JudgeIng.ets b/entry/src/main/ets/pages/Judge/JudgeIng.ets index 42e2793..8f88283 100644 --- a/entry/src/main/ets/pages/Judge/JudgeIng.ets +++ b/entry/src/main/ets/pages/Judge/JudgeIng.ets @@ -1,4 +1,4 @@ -import { JudgeTag } from '../../config'; +import { JudgeConfig, JudgeTag } from '../../config'; import { JudgeCallBackData, JudgeConfigObj, @@ -10,9 +10,10 @@ import { ProjectInfo } from '../../model'; import { dConsole } from '../../utils/LogWorker'; +import { endRecordVideo } from '../../utils/Video'; import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'; import JudgeBusiness from './JudgeBusiness'; -import { examJudgeArtificialItem, examJudgeSoundEnd } from './JudgeSDKUtils'; +import { examJudgeArtificialItem, examJudgeEndExam, examJudgeSoundEnd } from './JudgeSDKUtils'; import { ProjectStart, UploadProgressPhoto } from './ProcessDataProcessing'; import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils'; @@ -196,11 +197,16 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju //项目名称 考车状态 扣分arr xmmcStr: that.xmmcStr, carztStr: that.carztStr, kfArr: that.kfArr }); - + // TODO 语音播报 + changeExamStatus(event, xmdm, that.kfArr, judgeUI, that); + // 更新ui + if (event == 1 || event == 2 || event == 3 || event == 6) { + judgeUI.projectsObj = JSON.parse(JSON.stringify(judgeUI.projectsObj)) + } } const goJudgeVoice = async (sound: JudgeSound, avPlayer: VoiceAnnounce) => { - dConsole.info('surenjun code=>', JSON.stringify(sound.code)) + dConsole.info(JudgeTag, 'surenjun code=>', JSON.stringify(sound.code)) //判断是不是模拟灯光语音 if (sound.type == 1) { avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { @@ -270,7 +276,260 @@ const changeExamStatus = async (event: number, xmdm: number, kf: MarkRule[], jud break; } case 2: { + dConsole.log(JudgeTag, "项目结束判定1") + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + const isStart = await checkProjectIsStart(xmdm, 2, judgeUI, that) + + if (isStart) { + // 项目结束了就不再生成数据 + dConsole.info(JudgeTag + ' projectIsEnd =>', project.isEnd) + if (!project.isEnd) { + // judgeTask.addTask(async () => { + // dConsole.info(JudgeTag, `项目结束-${xmdm}-${project.name}`) + // await endProject(xmdm); + // this.xmmcSingleCode = '0'; + // this.xmmcEndCode = undefined; + // }, { + // isDelay: true + // }) + } + } + dConsole.log(JudgeTag, "项目结束判定3") + try { + const param512: JudgeConfigObj = (Reflect.get(judgeUI.judgeConfigObj, '512') || '').split(','); + if (!judgeUI.isProjectIn) { + that.deductedPopShowTimer = setTimeout(() => { + judgeUI.isDeductedPopShow = false + }, (Reflect.get(param512!, 5) || 0) * 1000) + } + } catch (e) { + dConsole.error(JudgeTag, "项目结束后弹窗定时器异常", e) + } + project.isEnd = true; + dConsole.log(JudgeTag, "项目结束判定4") break; } + case 3: { + dConsole.log(JudgeTag, "扣分开始") + const currentKf = kf[kf.length -1]; + if (JudgeConfig.kfVoiceOpen || (judgeUI.examSubject == "2" && Reflect.get(judgeUI.judgeConfigObj, '618') === "1") || (judgeUI.examSubject == "3" && Reflect.get(judgeUI.judgeConfigObj, '418') === "1")) { + that.avPlayer?.playAudio([`voice/${currentKf.markcatalog}.mp3`, + `voice/mark_${Math.abs(currentKf?.score || 0)}.mp3`]) + } + const isStart = await checkProjectIsStart(Number(currentKf.xmdm), 2, judgeUI, that); + if (isStart) { + // await judgeTask.addTask(async () => { + // dConsole.info(JudgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`) + // await pointsDedute(Number(currentKf.xmdm), currentKf) + // }, { + // isDelay: true + // }) + } + break + } + case 5: { + dConsole.log(JudgeTag, "考试结束") + const singlePlay = AppStorage.get('singlePlay') + // 关闭录像 + if (!singlePlay && that.videoData) { + await endRecordVideo(that.videoData) + } + // judgeTask.addTask(async () => { + // dConsole.info(JudgeTag, '考试结束 start') + // AppStorage.setOrCreate('isJudge', false) + // await handEndExam() + // }) + break + + } + default: + break } + if (event === 2 || event === 3) { + dConsole.log(JudgeTag, "项目结束判定统计项目") + await setCountItems(judgeUI); + await checkExamIsEnd(judgeUI, that) + } +} +/** + * 校验考试是否结束 + */ +const checkExamIsEnd = async (judgeUI: JudgeUI, that: JudgeBusiness, isManual?: boolean) => { + dConsole.log(JudgeTag, "校验考试是否结束") + const totalScore = Number(judgeUI.totalScore) + const judgeConfigObj = judgeUI.judgeConfigObj + const examMileage = Number(judgeUI.examMileage) + const passingScore = Number(judgeUI.passingScore) + if (that.isExamEnd) { + return + } + if (isManual) { + // 考试不合格 + await examJudgeEndExam() + that.isExamEnd = true + that.isManual = true + } else { + const param302: number = Reflect.get(judgeUI.judgeConfigObj, '302') + const param342: number = Reflect.get(judgeUI.judgeConfigObj, '342') + const param512: number[] = (Reflect.get(judgeUI.judgeConfigObj, '512') || '').split(','); + if (judgeUI.singlePlay) { + // 单机模式 + dConsole.info(JudgeTag + ' 单机模式结束 => ', judgeUI.isAllProjectsEnd) + if (judgeUI.isAllProjectsEnd && judgeUI.jl >= examMileage) { + // 成绩合格 + if (totalScore >= passingScore && !that.isEndTip) { + if (judgeUI.examSubject == '3' && (param342 == 0 || param342 == 2) && + (param302 != 6 && param302 != 7 && param302 != 8)) { + if (param512[7] != 0) { + clearTimeout(that.deductedPopShowTimer) + that.avPlayer?.playAudio(['voice/综合评判.mp3']) + judgeUI.isDeductedPopShow = true + judgeUI.defaultTabIndex = 1 + that.isEndTip = true + return + } + } else { + await examJudgeEndExam() + that.isExamEnd = true + return + } + } else { + if (judgeUI.examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) { + await examJudgeEndExam() + that.isExamEnd = true + return + } + } + await examJudgeEndExam() + that.isExamEnd = true + } + } else { + // 非单机模式 + //成绩不合格 + if (totalScore < passingScore) { + //科目三不合格报靠边停车 + if (judgeUI.examSubject == '3' && param302 == 1) { + that.avPlayer?.playAudio([`voice/考试结束.mp3`]); + return + } + await examJudgeEndExam() + that.isExamEnd = true + return + } + // 成绩合格 + if (judgeUI.isAllProjectsEnd && totalScore >= passingScore && !that.isEndTip) { + // 科目二成绩合格 + if (judgeUI.examSubject == '2') { + await examJudgeEndExam() + that.isExamEnd = true + return + } + //考试里程判断 + if (judgeUI.examSubject == '3' && judgeUI.jl < examMileage) { + return + } + //考试合格自动退出 + if (judgeUI.examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) { + await examJudgeEndExam() + that.isExamEnd = true + return + } + if (judgeUI.examSubject == '3' && (param342 == 0 || param342 == 2) && + (param302 != 6 && param302 != 7 && param302 != 8)) { + if (param512[7] != 0) { + clearTimeout(that.deductedPopShowTimer) + judgeUI.isDeductedPopShow = false + that.avPlayer?.playAudio(['voice/综合评判.mp3']) + judgeUI.isDeductedPopShow = true + judgeUI.defaultTabIndex = 1 + that.isEndTip = true + } + } else { + await examJudgeEndExam() + that.isExamEnd = true + } + } + } + } +} +/** + * 统计必考项目,所有项目,已考数量 + */ +const setCountItems = async (judgeUI: JudgeUI) => { + dConsole.log(JudgeTag, "项目结束判定,统计考试项目") + const projectsObj: object = judgeUI.projectsObj; + //必考项目数量 必考项目已考数量 所有考试项目数量 项目已考项目数量 + let projectNum = 0, endProjectsNum = 0, allProjectNum = 0, allEndProjectsNum = 0; + Reflect.ownKeys(projectsObj).forEach(projectKey => { + const projectObj: ProjectInfo = Reflect.get(projectsObj, projectKey) + const type = projectObj.type + const isRequired = projectObj.isRequired + allProjectNum += 1; + if (type == '3' || type == '4') { + allEndProjectsNum += 1; + } + + if (isRequired) { + projectNum += 1; + if (type == '3' || type == '4') { + endProjectsNum += 1; + } + } + }) + dConsole.info(JudgeTag, '项目状态projectsObj:' + JSON.stringify(projectsObj)); + dConsole.info(JudgeTag, '所有考试项目数量:' + allProjectNum) + dConsole.info(JudgeTag, '必考项目数量:' + projectNum) + dConsole.info(JudgeTag, '必考项目已考数量:' + endProjectsNum) + //必考项目除靠边停车是否全部完成 + judgeUI.isRequiredProjectsEnd = (projectNum - endProjectsNum === 0) + judgeUI.isAllProjectsEnd = (allProjectNum - allEndProjectsNum === 0) +} +/** + * 检测扣分、结束项目时该项目是否开始 + * + */ +const checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, judgeUI: JudgeUI, that: JudgeBusiness, kf?: MarkRule,): Promise => { + if (xmdm == 20) { + return true + } + const currentProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + + if (currentProject.isUpload) { + dConsole.info(JudgeTag, '项目补传开始') + // judgeTask.addTask(async () => { + // await this.beginProject(xmdm) + // }, { + // isDelay: true + // }) + // judgeTask.addTask(async () => { + // await this.uploadProgressPhoto(xmdm) + // }, { + // isDelay: true + // }) + currentProject.isUpload = true; + Reflect.set(judgeUI.projectsObj, xmdm, currentProject) + if (currentType == 2) { + //项目结束需要等补传完毕 + // judgeTask.addTask(async () => { + // await this.pointsDedute(xmdm, kf!) + // }, { + // isDelay: true + // }) + } + //扣分补传判断是否合格 不合格补传项目结束 + if (currentType == 1 || (currentType == 2 && that.totalScore < judgeUI.passingScore)) { + // judgeTask.addTask(async () => { + // await this.endProject(xmdm) + // }, { + // isDelay: true + // }) + currentProject.isEnd = true; + Reflect.set(judgeUI.projectsObj, xmdm, currentProject) + } + // judgeTask.addTask(async () => { + // this.checkExamIsEnd() + // }) + return false; + } + return true } \ No newline at end of file diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index b93c9b2..0132a91 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -42,7 +42,7 @@ import { GetCurrentTime, GetPhotoBase64, NumberToByteArray } from '../utils/Comm import DB from '../utils/DbSql'; import { CenterUDPBusinessInstance } from '../utils/business/CenterUdpBusiness'; import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; -import { StartExamTag, UserInfoTag } from '../config'; +import { StartEndExamTag, StartExamTag, UserInfoTag } from '../config'; import { dConsole } from '../utils/LogWorker'; import HeaderComponent from './compontents/Header'; import AvatarComponent from './UserInfo/Avatar'; @@ -186,6 +186,7 @@ struct UserInfoPage { // 初始化开始考试过程数据文件夹 InitializeExamProcessData(this.currentUser) dConsole.log(StartExamTag, '开始考试4') + dConsole.log(StartEndExamTag, "-----------------------------身份证号:" + this.currentUser.sfzmhm + "考生开始考试-----------------------------") router.pushUrl({ url: this.carInfo.examSubject == '3' ? 'pages/Roads' : 'pages/Judge', params: { diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index f9e171e..5ad656c 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -6,7 +6,7 @@ import buffer from '@ohos.buffer'; import VoiceAnnounce from './utils/voiceAnnouncements'; import FileModel from './utils/fileModel'; import JudgeTask from './utils/judgeTask'; -import { JudgeConfig, JudgeTag } from '../../config'; +import { JudgeConfig, JudgeTag, StartEndExamTag } from '../../config'; import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; @@ -107,13 +107,11 @@ export default class Judge { serial, type }) - // await this.fileLog?.setExamJudgeData(str) dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, str) dConsole.info(JudgeTag, `人工扣分-${itemno}-${serial}`) } //人工操作项目 public setJudgeItem = async (itemno: string, type: 1 | 2) => { - // const { fileLog } = this; await examJudgeArtificialItem(Number(itemno), type); const str = JSON.stringify({ method: 'examJudgeArtificialItem', @@ -1433,6 +1431,7 @@ export default class Judge { return } dConsole.info(JudgeTag, '考试结束 end') + dConsole.log(StartEndExamTag, "-----------------------------身份证号:" + this.judgeUI.idCard + "考生结束考试-----------------------------") const param302: string = Reflect.get(judgeConfigObj, '302') // judgeUI.loadingPopupVisible = true; dConsole.log(JudgeTag, ' 打开车辆loading2') diff --git a/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets b/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets index 2d0c3ee..1e26c7f 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets @@ -224,4 +224,4 @@ class AVPlayer { } }) } -} \ No newline at end of file +}