From d6a5c9fdba294604551cf6c4cd00fde148396746 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Wed, 20 Aug 2025 14:58:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=96=B0=E8=AF=84?= =?UTF-8?q?=E5=88=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/config/LogEnum.ets | 4 +- entry/src/main/ets/model/Worker.ets | 2 +- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/pages/Index/utils.ets | 2 +- entry/src/main/ets/pages/Judge.ets | 1 - .../main/ets/pages/Judge/JudgeBusiness.ets | 10 +- entry/src/main/ets/pages/Judge/JudgeIng.ets | 153 ++++++++++++--- .../main/ets/pages/Judge/JudgeVariable.ets | 28 --- .../ets/pages/Judge/ProcessDataProcessing.ets | 182 ++++++++++++++++++ entry/src/main/ets/pages/Judge/utils.ets | 54 ++++++ 10 files changed, 380 insertions(+), 58 deletions(-) delete mode 100644 entry/src/main/ets/pages/Judge/JudgeVariable.ets create mode 100644 entry/src/main/ets/pages/Judge/ProcessDataProcessing.ets diff --git a/entry/src/main/ets/config/LogEnum.ets b/entry/src/main/ets/config/LogEnum.ets index f4e3854..da2fbe4 100644 --- a/entry/src/main/ets/config/LogEnum.ets +++ b/entry/src/main/ets/config/LogEnum.ets @@ -70,4 +70,6 @@ export const SignDisplayTag = '[SignDisplay]'; export const StartExamTag = '[StartExam]' //人脸对比 -export const FaceCompareTag = '[FaceCompare]'; \ No newline at end of file +export const FaceCompareTag = '[FaceCompare]'; +//过程数据处理 +export const ProcessDataTag = '[ProcessData]'; \ No newline at end of file diff --git a/entry/src/main/ets/model/Worker.ets b/entry/src/main/ets/model/Worker.ets index a02bc54..6f39e65 100644 --- a/entry/src/main/ets/model/Worker.ets +++ b/entry/src/main/ets/model/Worker.ets @@ -63,7 +63,7 @@ export enum ProcessDataEnumType { JudgeExamData = "2", //judge_log_data JudgeLogData = "3", - // judge_progress_callback_data + //judge_progress_callback_data JudgeProgressCallbackData = "4", //plc_data PlcData = "5", diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index d5ec638..7d2ce77 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -189,7 +189,7 @@ struct Index { dConsole.log("test1111") await GetDeviceInfo(this.context) this.carInfo = await GetCarInfo() - this.carInfo = AppStorage.get('carInfo')! + AppStorage.setOrCreate("carInfo", this.carInfo) this.deviceId = this.carInfo.carNo || "" await SetCurrentTime() this.timeInfo = AppStorage.get('timeInfo')! diff --git a/entry/src/main/ets/pages/Index/utils.ets b/entry/src/main/ets/pages/Index/utils.ets index ba82d8f..f313f91 100644 --- a/entry/src/main/ets/pages/Index/utils.ets +++ b/entry/src/main/ets/pages/Index/utils.ets @@ -48,7 +48,7 @@ export async function GetCarInfo(): Promise { deviceNo: AppStorage.get('deviceNo') || "" }; let res: ApiResponseType = await obtainCarExamInfo(params) - dConsole.log("获取到的车辆信息", res) + dConsole.log("90", res) if (res.obtainCarExamInfoRsp && res.obtainCarExamInfoRsp.body) { const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! carInfo.plateNo = decodeURIComponent(carInfo.plateNo) diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 9b05d7d..1184498 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -396,7 +396,6 @@ struct JudgePage { Reflect.set(this.projectsObj, 1, project_1) } Reflect.set(this.judgeConfigObj, sys.v_no!, value) - dConsole.log("寻找", this.judgeConfigObj) }); this.judgeConfig = syssetJudgeConfigArr; } diff --git a/entry/src/main/ets/pages/Judge/JudgeBusiness.ets b/entry/src/main/ets/pages/Judge/JudgeBusiness.ets index b24bafb..3709167 100644 --- a/entry/src/main/ets/pages/Judge/JudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/JudgeBusiness.ets @@ -1,7 +1,9 @@ import { JudgeConfigObjKmItems, + JudgeKSJS, JudgePerformInfo, JudgeUI, + LANE, MarkRule, PLCType, ProcessDataEnumType, @@ -22,6 +24,10 @@ import { PlcStrToJson, PlcStrToWXJson } from './utils' import { JudgeEndFn } from './JudgeEnd' export default class JudgeBusiness { + public mndgStr: string | undefined + public lane: LANE = { + road: '', num: 0, count: 0 + } public fileUtil: FileUtils public avPlayer?: VoiceAnnounce public performInfo?: JudgePerformInfo @@ -31,7 +37,7 @@ export default class JudgeBusiness { public isEndTip: boolean = false; //是否手动结束考试 public isManual: boolean = false - public deductedPopShowTimer: number = 0; + public deductedPopShowTimer: number = -1; public videoData?: RecordHandleType //是否是考试模式 public isExam: boolean @@ -48,12 +54,12 @@ export default class JudgeBusiness { public xmxh: string = "" public kfArr?: MarkRule[] public carztStr: string + public ksjs?: JudgeKSJS private judgeUI: JudgeUI private tempData?: PLCType private plcData?: PLCType // 是否发送udp private isUdpEnd: boolean = false - private mndgStr: string | undefined constructor(judgeUI: JudgeUI) { this.judgeUI = judgeUI diff --git a/entry/src/main/ets/pages/Judge/JudgeIng.ets b/entry/src/main/ets/pages/Judge/JudgeIng.ets index a4a8329..e8117a9 100644 --- a/entry/src/main/ets/pages/Judge/JudgeIng.ets +++ b/entry/src/main/ets/pages/Judge/JudgeIng.ets @@ -1,9 +1,19 @@ import { JudgeTag } from '../../config'; -import { JudgeCallBackData, JudgeUI, KmItem, MarkRule, ProcessDataEnumType, ProjectInfo } from '../../model'; +import { + JudgeCallBackData, + JudgeConfigObj, + JudgeSound, + JudgeUI, + KmItem, + MarkRule, + ProcessDataEnumType, + ProjectInfo +} from '../../model'; import { dConsole } from '../../utils/LogWorker'; +import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'; import JudgeBusiness from './JudgeBusiness'; -import { examJudgeArtificialItem } from './JudgeSDKUtils'; -import { CurrentProjectConversion, DeductionProjectConversion } from './utils'; +import { examJudgeArtificialItem, examJudgeSoundEnd } from './JudgeSDKUtils'; +import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils'; export const JudgingFn = async (strData: string, callBack: Function, judgeUI: JudgeUI, that: JudgeBusiness) => { let examData: JudgeCallBackData = JSON.parse(strData); @@ -26,13 +36,10 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju const isManualProjectIn = artSubject3ProjectsCodesArr.includes(xmdm); const examSubject = judgeUI.examSubject const judgeConfigObj = judgeUI.judgeConfigObj - let project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) - const xmmcCode = project.projectCodeCenter || ""; - const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) - switch (event) { // 项目开始 - case 1: + case 1: { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) project.type = '2'; if (isManualProjectIn) { //手动项目是否在进行中 @@ -44,6 +51,8 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju judgeUI.currentXmdm = xmdm; const xmmcStr = project.name || ""; const xmmcSingleCode = project.projectCode || ""; + const xmmcCode = project.projectCodeCenter || ""; + const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) kmItem.status = 2; that.xmmcStr = xmmcStr; that.xmmcCode = xmmcCode; @@ -55,10 +64,13 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju Reflect.set(judgeUI.projectsObj, xmdm, project) Reflect.set(that.kmItems, xmmcCode || 0, kmItem) break; + } // 项目结束 - case 2: + case 2: { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + const xmmcCode = project.projectCodeCenter || ""; project.type = (xmjs.xmhg === 0 ? '4' : '3') - //计算项目是否全部结束 + //计算项目是否全部结束 judgeUI.isProjectIn = (Reflect.ownKeys(judgeUI.projectsObj).filter((projectKey) => { const fillProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, projectKey) return fillProject.type == '2' @@ -66,8 +78,9 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju if (isManualProjectIn) { judgeUI.isManualProjectIn = false } + const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) kmItem.status = 3; - //统计必考项目数量 + //统计必考项目数量 that.xmmcStr = '无'; that.xmmcCode = ''; that.xmdm = ''; @@ -75,8 +88,9 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju Reflect.set(judgeUI.projectsObj, xmdm, project) Reflect.set(that.kmItems, xmmcCode, kmItem) break; + } // 扣分 - case 3: + case 3: { const thisKf = DeductionProjectConversion(`${kf.xmdm}_${kf.kfdm}`, judgeUI.markRuleListObj) const kfObj: MarkRule = { //扣分项目名称 @@ -104,32 +118,77 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju Reflect.set(judgeUI.projectsObj, kf.xmdm, project) } break; + } // 考试状态 - case 4: + case 4: { + that.carztStr = GetCarStatus(carzt); break; + } // 考试结束 - case 5: + case 5: { + that.ksjs = ksjs; + // await fileLog?.setExamJudgeData(JSON.stringify({ + // method: 'examJudgeEndExam' + // })) + dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ + method: 'examJudgeEndExam' + })) break; + } // 项目取消 - case 6: + case 6: { + dConsole.info(JudgeTag, '项目取消'); + const xmdm = xmqx.xmdm; + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + const xmmcCode = project.projectCodeCenter || ""; + project.type = '1' + const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) + Reflect.set(judgeUI.projectsObj, xmdm, project) + kmItem.status = 1 + Reflect.set(that.kmItems, xmmcCode, kmItem) break; + } // 语音播报和提示 - case 7: + case 7: { + goJudgeVoice(sound, that.avPlayer) break; + } // 模拟灯光事件 - case 8: + case 8: { + that.mndgStr = mndg break; + } // 车道和路段变化 - case 9: + case 9: { + judgeUI.lane = lane + that.lane = lane; break; + } // 预进项目事件 - case 10: - break; + case 10: { + const xmdm = precast.xmdm + const xmxh = precast.xmxh + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + const xmmcCode: string = judgeUI.projectsObj[xmdm].projectCodeCenter; + const xmmcSingleCode: string = judgeUI.projectsObj[xmdm].projectCode; + const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) + const xmmcStr = project?.name || ""; + kmItem.status = 2; + Reflect.set(that.kmItems, xmmcCode, project) + that.xmmcStr = xmmcStr || ""; + that.xmmcCode = xmmcCode || ""; + that.xmdm = xmdm; + that.xmxh = xmxh; + that.xmmcSingleCode = xmmcSingleCode || ""; + project.type = '2'; + Reflect.set(judgeUI.projectsObj, xmdm, project) + } // 差分事件 - case 11: + case 11: { + DetectingDifferences(nongps.type, that.avPlayer) break; + } default: - 83 break; } await callBack({ @@ -139,7 +198,25 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju } -// +const goJudgeVoice = async (sound: JudgeSound, avPlayer: VoiceAnnounce) => { + dConsole.info('surenjun code=>', JSON.stringify(sound.code)) + //判断是不是模拟灯光语音 + if (sound.type == 1) { + avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { + examJudgeSoundEnd({ + xmdm: sound.xmdm, code: sound.code[0], type: sound.type + }) + dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ + method: 'examJudgeSoundEnd', + itemno: sound.xmdm, + code: sound.code[0], + type: sound.type, + })) + }) + } else { + avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`]) + } +} export const SetJudgeItem = async (itemno: string, type: 1 | 2) => { @@ -151,4 +228,34 @@ export const SetJudgeItem = async (itemno: string, type: 1 | 2) => { }) dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, str) dConsole.info(JudgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`) +} + +const changeExamStatus = async (event: number, xmdm: number, kf: MarkRule[], judgeUI: JudgeUI, that: JudgeBusiness) => { + switch (event) { + case 1: { + const param512: JudgeConfigObj = (Reflect.get(judgeUI.judgeConfigObj, '512') || '').split(','); + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + setTimeout(() => { + if (Reflect.get(param512, 7) != 0) { + clearTimeout(that.deductedPopShowTimer) + judgeUI.isDeductedPopShow = true + } + }, 200) + if (!project.isEnd) { + that.judgeTask.addTask(async () => { + dConsole.info(JudgeTag, `项目开始-${xmdm}-${project.name}`) + await beginProject(xmdm) + }, { + isDelay: true + }) + that.judgeTask.addTask(async () => { + dConsole.info(JudgeTag, `项目-${xmdm}-上传照片 start`) + await uploadProgressPhoto(xmdm) + }, { + isDelay: true + }) + } + break; + } + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge/JudgeVariable.ets b/entry/src/main/ets/pages/Judge/JudgeVariable.ets deleted file mode 100644 index fb241fa..0000000 --- a/entry/src/main/ets/pages/Judge/JudgeVariable.ets +++ /dev/null @@ -1,28 +0,0 @@ -import { testKm2Items, testKm3Items } from '../../mock'; -import { JudgeConfigObjKmItems, ProjectInfo, ProjectInfos } from '../../model'; - -class judgeVariable { - public rmndg: 0 | 1 = 0 - public kmItems: JudgeConfigObjKmItems = {} - public xmmcStr: string = "" - public xmmcEndCode?: string = "" - public xmxh: string = "" - public status: string = "开始" - - constructor() { - - } - - public initKmItems(examSubject: string, projectsCenterObj: ProjectInfos) { - (examSubject == '2' ? testKm2Items : testKm3Items).forEach(item => { - const projectCenterObj: ProjectInfo = Reflect.get(projectsCenterObj, item.code) - Reflect.set(this.kmItems, item.code, { - code: item.code, - status: projectCenterObj === undefined ? 0 : (projectCenterObj.isEnd ? 3 : 1) - }) - }) - - } -} - -export const JudgeVariable = new judgeVariable(); \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge/ProcessDataProcessing.ets b/entry/src/main/ets/pages/Judge/ProcessDataProcessing.ets new file mode 100644 index 0000000..c704e73 --- /dev/null +++ b/entry/src/main/ets/pages/Judge/ProcessDataProcessing.ets @@ -0,0 +1,182 @@ +/** + * 过程数据处理 + */ +import { ProcessDataTag } from '../../config'; +import { + CarInfoType, + CDSBInfo, + CDSBInfos, + DrvexamType, + JudgeUI, + MarkRule, + PLCType, + ProjectInfo, + RegulatoryInterfaceParams +} from '../../model'; +import { GetPhotoBase64 } from '../../utils/Common'; +import dayTs from '../../utils/Date'; +import { dConsole } from '../../utils/LogWorker'; + +/** + * beginProject 项目开始 + */ +export const ProjectStart = (ksxm: number, xmxh: string, judgeUI: JudgeUI) => { + const carInfo = AppStorage.get('carInfo'); + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const sbxh = getSBXH(ksxm, xmxh, judgeUI.cdsbInfoObj, judgeUI.projectsObj, carInfo.examSubject); + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, + kskm: carInfo?.examSubject || "2", + sfzmhm: judgeUI.idCard, + ksxm: project.projectCodeCenter, + sbxh, + ksxl: judgeUI.xldm, + kchp: encodeURI(carInfo?.plateNo || ""), + ksdd: encodeURI(judgeUI.ksdd), + kslx: encodeURI(judgeUI.kslx) || '', + kssj: dayTs().format("YYYY-MM-DD HH:mm:ss") + } + const data: RegulatoryInterfaceParams = { + //系统类别 接口序列号 接口标识 + xtlb: '17', + jkxlh: judgeUI.serialNumber, + jkid: '17C52', + drvexam + } + dConsole.log(ProcessDataTag, "项目开始数据处理", data) +} + +/** + * uploadProgressPhoto 上传过程照片 + */ +export const UploadProgressPhoto = async (ksxm: number, plcData: PLCType, judgeUI: JudgeUI) => { + const photoBase64 = await GetPhotoBase64(judgeUI.context); + const carInfo = AppStorage.get('carInfo'); + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305') + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, + kskm: carInfo?.examSubject || "2", + ksxm: project.projectCodeCenter, + sfzmhm: judgeUI.idCard, + kchp: encodeURI(carInfo?.plateNo || ""), + zpsj: dayTs().format("YYYY-MM-DD HH:mm:ss"), + zp: photoBase64, + cs: Math.floor((judgeConfig_305 == 0 ? (plcData?.gps?.sd || 0) : (plcData?.sensor?.cs || 0)) * 1.852), + ksdd: encodeURI(judgeUI.ksdd) + } + const data: RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: judgeUI.serialNumber, + jkid: '17C54', + drvexam + }; + dConsole.log(ProcessDataTag, "上传过程照片数据处理", data); +} + +/** + * pointsDedute 扣分补传 + */ +export const DeductPoints = (ksxm: number, kf: MarkRule, xmmcEndCode: string, judgeUI: JudgeUI) => { + const carInfo = AppStorage.get('carInfo')!; + const examSubject = carInfo.examSubject + const lsh = judgeUI.lsh + const idCard = judgeUI.idCard + const serialNumber = judgeUI.serialNumber + const ksdd = judgeUI.ksdd + const projectsObj: object = judgeUI.projectsObj + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + //科目三夜间行驶.模拟灯光、上车准备出现通用评判,ksxm为当前进行的项目 + const checkProjects = ['17', '41', '1']; + //获取正在进行的项目 + const inProjects = Reflect.ownKeys(projectsObj).filter(projectKey => { + const project: ProjectInfo = Reflect.get(projectsObj, projectKey) + return project.type == '2' + }); + let commonKsxm = ''; + checkProjects.forEach(projectCode => { + if (inProjects.includes(projectCode)) { + commonKsxm = projectCode + } + }) + let ksxmD: string; + if (!project) { + if (commonKsxm) { + ksxmD = Reflect.get(projectsObj, commonKsxm).projectCodeCenter; + } else { + if (examSubject == '3') { + ksxmD = '30000'; + } else { + ksxmD = (xmmcEndCode == undefined ? '10000' : xmmcEndCode); + } + } + } else { + ksxmD = project?.projectCodeCenter || ""; + } + const drvexam: DrvexamType = { + lsh, + kskm: examSubject, + ksxm: ksxmD, + kfxm: kf.markcatalog, + kfxmmx: `${ksxm},${kf.markserial}`, + sfzmhm: idCard, + kchp: encodeURI(carInfo?.plateNo || ""), + //扣分方式 + kffs: kf.type == 0 ? 1 : 2, + ksdd: encodeURI(ksdd), + kfsj: dayTs().format("YYYY-MM-DD HH:mm:ss"), + } + const data: RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: serialNumber, + jkid: '17C53', + drvexam + } + dConsole.log(ProcessDataTag, "扣分上传数据", data) +} + +/** + * endProject 结束项目 + */ +export const ProjectEnd = (ksxm: number, xmxh: string, judgeUI: JudgeUI) => { + const carInfo = AppStorage.get('carInfo'); + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const sbxh = carInfo.examSubject == '3' ? undefined : getSBXH(ksxm, xmxh, judgeUI.cdsbInfoObj, judgeUI.projectsObj, carInfo.examSubject); + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, + kskm: carInfo?.examSubject || "2", + sfzmhm: judgeUI.idCard, + ksxm: project.projectCodeCenter, + sbxh, + //TODO 操作类型 1:正常 0:撤销该考试记录 + czlx: '1', + ksxl: judgeUI.xldm, + kchp: encodeURI(carInfo?.plateNo || ""), + ksdd: encodeURI(judgeUI.ksdd), + kslx: encodeURI(judgeUI.kslx) || '', + jssj: dayTs().format("YYYY-MM-DD HH:mm:ss") + } + const data: RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: judgeUI.serialNumber, + jkid: '17C55', + drvexam + } + dConsole.log(ProcessDataTag, "结束项目数据", data) +} + + +const getSBXH = (ksxm: number, xmxh: string, cdsbInfoObj: CDSBInfos, projectsObj: object, examSubject: string): string => { + const project: ProjectInfo = Reflect.get(projectsObj, ksxm); + //科目三不需要 + if (examSubject == '3') { + return "" + } + if (project === undefined) { + return '00000000' + } + const projectKey = `${ksxm}_${xmxh}`; + const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj!, projectKey) || {} + const sbxh: string = currentCdsb.sbbm || '00000000' + return sbxh +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge/utils.ets b/entry/src/main/ets/pages/Judge/utils.ets index dfb88e2..c804cf0 100644 --- a/entry/src/main/ets/pages/Judge/utils.ets +++ b/entry/src/main/ets/pages/Judge/utils.ets @@ -6,9 +6,11 @@ import { DefaultJudgeConfigObj, ExtendType, Gps, + JudgeSound, LANE, MarkRule, PLCType, + ProcessDataEnumType, ProjectInfo, ProjectInfos, ProjectRoads, @@ -18,6 +20,8 @@ import { import { ArrayToByteArray, NumberToByteArray } from '../../utils/Common'; import dayTs from '../../utils/Date'; import { dConsole } from '../../utils/LogWorker'; +import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'; +import { examJudgeSoundEnd } from './JudgeSDKUtils'; // 中心信号转换 @@ -852,4 +856,54 @@ export const DeductionProjectConversion = (code: string, markRuleListObj: object export const CurrentProjectConversion = (code: number, projectsObj: object): string => { const project: ProjectInfo = Reflect.get(projectsObj, code) return project?.abbreviation || '通用评判' +} + +/** + * 获取评判语音 + * @param sound - 评判音频对象 + * @param avPlayer - 语音播放器实例 + */ +export function PlayJudgeVoice(sound: JudgeSound, avPlayer: VoiceAnnounce) { + if (sound.type == 1) { + avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { + examJudgeSoundEnd({ + xmdm: sound.xmdm, code: sound.code[0], type: sound.type + }); + dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ + method: 'examJudgeSoundEnd', + itemno: sound.xmdm, + code: sound.code[0], + type: sound.type, + })); + }); + } else { + avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`]); + } +} + +/** + * 检查差分 + */ +export const DetectingDifferences = async (type: number, avPlayer: VoiceAnnounce): Promise => { + switch (type) { + case 0: + return true; + case 1: + avPlayer?.playAudio([`voice/差分状态异常.mp3`], true) + // setTimeout(() => { + // router.back() + // }, 3000) + return true + case 2: + avPlayer?.playAudio([`voice/差分状态异常.mp3`], true); + return false + case 3: + avPlayer?.playAudio([`voice/差分状态异常.mp3`], true); + return true + case 4: + //差分异常上报 + return false + default: + return true + } } \ No newline at end of file