diff --git a/entry/src/main/ets/model/Common.ets b/entry/src/main/ets/model/Common.ets index af73217..15363de 100644 --- a/entry/src/main/ets/model/Common.ets +++ b/entry/src/main/ets/model/Common.ets @@ -112,7 +112,7 @@ export interface CarInfoType { examinationRoomId?: string; plateNo?: string; carNo?: string; - examSubject: string; + examSubject?: string; isNeedCheck?: string; udpAddress?: string messagePort?: string diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index ebcb32d..e659158 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -120,7 +120,6 @@ struct Index { @State isDeductedPopShow: boolean = false @State isAmplifyPopShow: boolean = false @State amplifiedImgIndex: number = 0 - judge: Judge //行驶距离 @State jl: number = 0 //应考里程 @@ -162,6 +161,7 @@ struct Index { @State isErrorMsgEnd: boolean = false @State disConnectErrorOpen: boolean = false public context = getContext(this) as common.UIAbilityContext; + private judge: Judge = new Judge(this) async aboutToDisappear() { clearInterval(this.mileageTimer) @@ -185,8 +185,7 @@ struct Index { //断点续考 await this.goDdxkItems() //初始化评判 - const judge = await this.initJudge(); - this.judge = judge + await this.initJudge(); } //初始化相关数据库表 @@ -522,16 +521,12 @@ struct Index { // 评判相关初始化 async initJudge() { - const JUDGEUI: JudgeUI = this; - const judge = new Judge(JUDGEUI); - // await judge.init() - await judge.onJudgeFn(async (judgeData: JudgeCallBacData) => { - // const { xmmcStr, carztStr, kfArr } = judgeData; + ; + await this.judge.onJudgeFn(async (judgeData: JudgeCallBacData) => { this.xmmcStr = judgeData.xmmcStr || ""; this.carztStr = judgeData.carztStr || ""; this.kfArr = judgeData.kfArr || []; }); - return judge } // 断点续考判断 diff --git a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets index 21e11a1..711a284 100644 --- a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets +++ b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets @@ -339,7 +339,7 @@ export default struct DeductedPopup { } if (mark.itemno == 1 && Number(mark.markserial) > 100 && Number(mark.markserial) < 200) { - this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = { + Reflect.set(this.markRuleListObj, `${mark.itemno}_${mark.markserial}`, { itemno: tempObj.itemno, markcatalog: tempObj.markcatalog, markshow: tempObj.markshow, @@ -350,11 +350,9 @@ export default struct DeductedPopup { OnlyOneKind: tempObj.OnlyOneKind, NoCancelId: tempObj.NoCancelId, GPS_SID: tempObj.GPS_SID, - }; - + }) this.universalMarkRules.push(tempObj) } - }) } diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index e675df8..3d2064a 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -41,6 +41,7 @@ import { BaseInfoType, CarInfoType, CDSBInfo, + CDSBInfos, DrvexamType, ExaminerInfoType, ItemInfo, @@ -83,7 +84,7 @@ type GetDqxmStr = (xmdm: number) => string type TJudgeBeginObj = JudgeBeginObj export default class Judge { - public plcStr!: string + public plcStr: string = "" public judgeUI: JudgeUI //获取科目三的评判初始化配置 getKm3JudgeInitConfig: GetKm3JudgeInitConfig = async () => { @@ -92,8 +93,8 @@ export default class Judge { map_point_item: this.judgeUI.mapPointItemArr, //科目三暂时为空 iteminfo: [], - roads: this.getModelData('km3/Roads.txt'), - sharps: this.getModelData('km3/Sharps.txt') + roads: this.getModelData('km3/Roads.txt') || "", + sharps: this.getModelData('km3/Sharps.txt') || "" } } private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; @@ -785,7 +786,7 @@ export default class Judge { const kssycs = judgeUI.kssycs const isDdxk = judgeUI.isDdxk const ddxkTime = judgeUI.ddxkTime - const projectsCenterObj = judgeUI.projectsCenterObj + const projectsCenterObj: object = judgeUI.projectsCenterObj const ddxkKsxmArr = judgeUI.ddxkKsxmArr const ddxkKfArr = judgeUI.ddxkKfArr const passingScore = judgeUI.passingScore @@ -893,9 +894,9 @@ export default class Judge { this.rmndg = 1 } this.judgeUI.currentXmdm = xmdm; - const xmmcStr = project?.name || ""; - const xmmcCode = project?.projectCodeCenter || ""; - const xmmcSingleCode = project?.projectCode || ""; + const xmmcStr = project.name || ""; + const xmmcCode = project.projectCodeCenter || ""; + const xmmcSingleCode = project.projectCode || ""; const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) kmItem.status = 2; this.xmmcStr = xmmcStr; @@ -1018,18 +1019,18 @@ export default class Judge { const xmxh = precast.xmxh const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) - const projectCode = project.projectCode - const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; + // const projectCode = project.projectCode + const xmmcCode: string = judgeUI.projectsObj[xmdm].projectCodeCenter; + const xmmcSingleCode: string = judgeUI.projectsObj[xmdm].projectCode; const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) const xmmcStr = project?.name || ""; kmItem.status = 2; Reflect.set(this.kmItems, xmmcCode, project) - this.xmmcStr = xmmcStr||""; - this.xmmcCode = xmmcCode||""; + this.xmmcStr = xmmcStr || ""; + this.xmmcCode = xmmcCode || ""; this.xmdm = xmdm; this.xmxh = xmxh; - this.xmmcSingleCode = xmmcSingleCode||""; + this.xmmcSingleCode = xmmcSingleCode || ""; project.type = '2'; Reflect.set(this.judgeUI.projectsObj, xmdm, project) } @@ -1047,10 +1048,10 @@ export default class Judge { }); //语音播报 - this.goVoiceAnnounce(event, xmdm, this.kfArr||[], xmjs, ksjs, xmxh) + this.goVoiceAnnounce(event, xmdm, this.kfArr || [], xmjs, ksjs, xmxh) //更新UI if (event == 1 || event == 2 || event == 3 || event == 6) { - const copyProjectsObj = this.judgeUI.projectsObj; + const copyProjectsObj: object = this.judgeUI.projectsObj; judgeUI.projectsObj = deepClone(copyProjectsObj); } } @@ -1071,8 +1072,8 @@ export default class Judge { const lane = this.lane const closeAllFiles = this.closeAllFiles - const projectsObj = judgeUI.projectsObj - const judgeConfigObj = judgeUI.judgeConfigObj + const projectsObj: object = judgeUI.projectsObj + const judgeConfigObj: object = judgeUI.judgeConfigObj const examSubject = judgeUI.examSubject const jl = judgeUI.jl const isAllProjectsEnd = judgeUI.isAllProjectsEnd @@ -1163,7 +1164,8 @@ export default class Judge { 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`]) + 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) { @@ -1185,7 +1187,7 @@ export default class Judge { console.info(judgeTag, '考试结束') //关闭录像 const singlePlay = AppStorage.get('singlePlay') - if (!singlePlay&&this.videoData) { + if (!singlePlay && this.videoData) { await endRecordVideo(this.videoData) } judgeTask.addTask(async () => { @@ -1228,10 +1230,10 @@ export default class Judge { const idCard = judgeUI.idCard const serialNumber = judgeUI.serialNumber const ksdd = judgeUI.ksdd - const projectsObj = judgeUI.projectsObj + const projectsObj: object = judgeUI.projectsObj const time = GetCurrentTime(); - const project = this.getProjectInfo(ksxm); + const project: ProjectInfo = this.getProjectInfo(ksxm); //科目三夜间行驶.模拟灯光、上车准备出现通用评判,ksxm为当前进行的项目 const checkProjects = ['17', '41', '1']; //获取正在进行的项目 @@ -1247,11 +1249,25 @@ export default class Judge { } }) - const ksxmD: string = project == undefined - ? (commonKsxm - ? (project?.projectCodeCenter||"") - : (examSubject == '3' ? '30000' : (xmmcEndCode == undefined ? '10000' : xmmcEndCode))) - : project.projectCodeCenter + // const ksxmD: string = !project + // ? (commonKsxm + // ? (project?.projectCodeCenter!) + // : (examSubject == '3' ? '30000' : (xmmcEndCode == undefined ? '10000' : xmmcEndCode))) + // : project.projectCodeCenter + 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, @@ -1259,7 +1275,7 @@ export default class Judge { kfxm: kf.markcatalog, kfxmmx: `${ksxm},${kf.markserial}`, sfzmhm: idCard, - kchp: encodeURI(carInfo?.plateNo||""), + kchp: encodeURI(carInfo?.plateNo || ""), //扣分方式 kffs: kf.type == 0 ? 1 : 2, ksdd: encodeURI(ksdd), @@ -1278,7 +1294,7 @@ export default class Judge { this.isJudgeDisConnect = true } console.info(judgeTag, '项目扣分 end') - promptWxCode('17C53', temp?.code||0) + promptWxCode('17C53', temp?.code || 0) } // 评判语音提示 goJudgeVoice = async (sound: JudgeSound) => { @@ -1369,9 +1385,9 @@ export default class Judge { // 考试结束 public endExam = async (isManual?: Boolean) => { const carInfo = AppStorage.get('carInfo')!; - const singlePlay = AppStorage.get('singlePlay')||false - const examSubject = carInfo?.examSubject||"2" - const plateNo = carInfo?.plateNo||"" + const singlePlay = AppStorage.get('singlePlay') || false + const examSubject = carInfo?.examSubject || "2" + const plateNo = carInfo?.plateNo || "" const judgeUI = this.judgeUI const ksjs = this.ksjs @@ -1393,11 +1409,11 @@ export default class Judge { // await uploadDisConnectData(); const time = GetCurrentTime(); const photoBase64 = await getPhoto(); - const d1 = ksjs?.d1||0; - const d2 = ksjs?.d2||0; - const d3 = ksjs?.d3||0; - const d4 = ksjs?.d4||0; - const d5 = ksjs?.d5||0; + const d1 = ksjs?.d1 || 0; + const d2 = ksjs?.d2 || 0; + const d3 = ksjs?.d3 || 0; + const d4 = ksjs?.d4 || 0; + const d5 = ksjs?.d5 || 0; const drvexam: DrvexamType = { lsh, @@ -1422,11 +1438,11 @@ export default class Judge { router.back() }, 90 * 1000) const temp = await this.sendWriteObjectOut(data, filePath); - promptWxCode('17C56', temp?.code||0) + promptWxCode('17C56', temp?.code || 0) if (temp.code != 1) { avPlayer?.playAudio(['voice/监管失败.mp3']) - this.judgeUI.errorMsg = decodeURIComponent(temp?.message||"") + this.judgeUI.errorMsg = decodeURIComponent(temp?.message || "") if (temp.code == 2300028 || temp.code == 2300007) { this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' @@ -1505,14 +1521,14 @@ export default class Judge { let score = 0; //结束考试时候是否播报一遍所有扣分 const param634: string = Reflect.get(judgeConfigObj, '634') - if (kfArr&&kfArr.length && ((examSubject == '2' && param634 == '1') || examSubject == '3')) { + if (kfArr && 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&&kfArr.length - 1 === index) { + if (kfArr && kfArr.length - 1 === index) { avPlayer?.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; closeAllFiles() @@ -1682,8 +1698,8 @@ export default class Judge { //获取场地序号 getSbxh: GetgSbbm = (ksxm, xmxh) => { const judgeUI = this.judgeUI; - const projectsObj = judgeUI.projectsObj; - const cdsbInfoObj = judgeUI.cdsbInfoObj; + const projectsObj: object = judgeUI.projectsObj; + const cdsbInfoObj: CDSBInfos = judgeUI.cdsbInfoObj!; const project: ProjectInfo = Reflect.get(projectsObj, ksxm); if (judgeUI.examSubject == '3') { return '0000000000' @@ -1693,24 +1709,24 @@ export default class Judge { } const projectKey = `${ksxm}_${xmxh}`; // const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} - const currentCdsb: CDSBInfo = (Reflect.get(cdsbInfoObj, projectKey) ?? {}) as CDSBInfo; + const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) ?? {} as CDSBInfo; const sbxh: string = currentCdsb.sbbh || '0000000000' return sbxh } getSbbm: GetgSbbm = (ksxm, xmxh) => { const judgeUI = this.judgeUI; const cdsbInfoObj = judgeUI.cdsbInfoObj; - const projectsObj = judgeUI.projectsObj; + const projectsObj: object = judgeUI.projectsObj; const project: ProjectInfo = Reflect.get(projectsObj, ksxm); //科目三不需要 if (judgeUI.examSubject == '3') { - return undefined + return "" } if (project === undefined) { return '00000000' } const projectKey = `${ksxm}_${xmxh}`; - const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj!, projectKey) || {} const sbxh: string = currentCdsb.sbbm || '00000000' return sbxh } @@ -1757,7 +1773,7 @@ export default class Judge { } // 统计必考项目、所有项目、已考数量 setCountItems = async () => { - const projectsObj = this.judgeUI.projectsObj; + const projectsObj: object = this.judgeUI.projectsObj; //必考项目数量 必考项目已考数量 let projectNum = 0, endProjectsNum = 0; // 所有考试项目数量 项目已考项目数量 @@ -1894,16 +1910,18 @@ export default class Judge { // globalThis.laneData = performInfo.lane; }) - let beginExamInfo: JudgeBeginObj|undefined = undefined + let beginExamInfo: JudgeBeginObj | undefined = undefined // 3.开始考试 if (isTrajectoryOpen) { beginExamInfo = JSON.parse(strArr[1]) - beginExamInfo.replay = 1 + beginExamInfo && (beginExamInfo.replay = 1) } else { beginExamInfo = await getJudgeBeginData() } await fileLog?.setExamJudgeData(JSON.stringify(beginExamInfo)) - await examJudgeBeginExam(beginExamInfo); + if (beginExamInfo) { + await examJudgeBeginExam(beginExamInfo); + } console.info(judgeTag, '6.开始考试注册完成') avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) diff --git a/entry/src/main/ets/pages/judgeSDK/utils/Common.ets b/entry/src/main/ets/pages/judgeSDK/utils/Common.ets index 2bdab66..6661bfe 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/Common.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/Common.ets @@ -16,7 +16,7 @@ export function chunkArr(arr: T[], size: number): T[][] { } //对象深拷贝 -export function deepClone(target: T): T { +export function deepClone(target: T): T { // 如果是对象,且不是原始值null if (typeof target === 'object' && target !== null) { // 创建容器