diff --git a/entry/src/main/ets/mock/Judge.ets b/entry/src/main/ets/mock/Judge.ets index 6b66155..d9a9490 100644 --- a/entry/src/main/ets/mock/Judge.ets +++ b/entry/src/main/ets/mock/Judge.ets @@ -264,7 +264,8 @@ export const DefaultJudgeConfigData: DefaultJudgeConfigObj = { //里程不够允许手工点靠边停车 param_387: '0', //监管模式有扣分续考(0-否++1-是+把上次未考完的扣分带下来重新考试) - param_432: '1' + param_432: '1', + param_634: "1" } //所有的科二 科目三项目 diff --git a/entry/src/main/ets/model/Judge.ets b/entry/src/main/ets/model/Judge.ets index 39e61bb..2a4cfe0 100644 --- a/entry/src/main/ets/model/Judge.ets +++ b/entry/src/main/ets/model/Judge.ets @@ -309,6 +309,7 @@ export interface ProjectInfo { isRequired?: boolean //项目状态:未做 正在做 及格 不及格 有扣分 type?: '1' | '2' | '3' | '4' | '5' + ykType?: '1' | '2' | '3' | '4' | '5' } /** 科目二项目代码 **/ diff --git a/entry/src/main/ets/pages/Judge/Typing.ets b/entry/src/main/ets/pages/Judge/BaseJudgeBussines.ets similarity index 58% rename from entry/src/main/ets/pages/Judge/Typing.ets rename to entry/src/main/ets/pages/Judge/BaseJudgeBussines.ets index d89ba6f..9eac85e 100644 --- a/entry/src/main/ets/pages/Judge/Typing.ets +++ b/entry/src/main/ets/pages/Judge/BaseJudgeBussines.ets @@ -1,8 +1,12 @@ import { CarInfoType, + JudgeBeginObj, + JudgeCallBackData, JudgeConfigObj, + JudgeInitObj, JudgeSound, JudgeUI, + KmItem, MarkRule, ProcessDataEnumType, Project, @@ -16,11 +20,21 @@ import { JudgePage } from "../Judge" import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements' import { dConsole } from '../../utils/LogWorker' import { JudgeConfig, JudgeTag } from '../../config' -import { examJudgeArtificialItem, examJudgeEndExam, examJudgeSoundEnd } from './JudgeSDKUtils' +import { + examJudgeArtificialItem, + examJudgeBeginExam, + examJudgeEndExam, + examJudgeInit, + examJudgeSetLogCallback, + examJudgeSetPerformCallback, + examJudgeSetRealExamCallback, + examJudgeSoundEnd +} from './JudgeSDKUtils' import { ProjectStart, UploadProgressPhoto } from './ProcessDataProcessing' -import { endRecordVideo } from '../../utils/Video' +import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video' import router from '@ohos.router' import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation' +import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils' export interface GetSysSetResult { @@ -291,15 +305,16 @@ export class BaseJudge { Reflect.ownKeys(projectsObj).forEach(projectKey => { const projectObj: ProjectInfo = Reflect.get(projectsObj, projectKey) const type = projectObj.type + const ykType = projectObj.ykType const isRequired = projectObj.isRequired allProjectNum += 1; - if (type == '3' || type == '4') { + if (type == '3' || type == '4' || ykType === "3" || ykType === "4") { allEndProjectsNum += 1; } if (isRequired) { projectNum += 1; - if (type == '3' || type == '4') { + if (type == '3' || type == '4' || ykType === "3" || ykType === "4") { endProjectsNum += 1; } } @@ -540,4 +555,368 @@ export class BaseJudge { } return true } + + async judgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness, beginExamInfo: JudgeBeginObj, initInfo: JudgeInitObj) { + const name = judgeUI.name + const kssycs = judgeUI.kssycs + // 处理远程扣分使用 + // 处理单机模式 + const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen; + const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); + const trajectoryPath = JudgeConfig.trajectoryPath; + let strArr: string[] = []; + if (isTrajectoryOpen) { + const folderPath = await that.fileUtil.initFolder(trajectoryPath); + const str: string = await that.fileUtil.readFile(folderPath) + strArr = str.split('\n') + } + //日志回调 + dConsole.info(JudgeTag, '1.进入评判入口') + await examJudgeSetLogCallback(6, async (level: number, info: string, len: number) => { + dConsole.log(JudgeTag, '评判日志:' + info) + dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info) + }) + + dConsole.info(JudgeTag, '2.注册日志回调完成') + + //相关评判初始化只做一次 + if (!isJudgeInitBool) { + dConsole.log(JudgeTag, "评判初始化参数", initInfo) + await examJudgeInit(initInfo); + AppStorage.setOrCreate('isJudgeInitBool', true) + dConsole.info(JudgeTag, '4.评判初始化完成') + } + AppStorage.setOrCreate('isJudge', true) + // 2.评判过程回调 + await examJudgeSetRealExamCallback(async (strData: string, len: number) => { + // 评判回调日志 + dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData, strData) + dConsole.info(JudgeTag, '评判回调数据', strData) + await this.judging(strData, callBack, judgeUI, that) + }) + await examJudgeSetPerformCallback(async (info: string) => { + dConsole.info('评判实时数据', info) + that.performInfo = JSON.parse(info) + const jl = Math.floor((that.performInfo!.qjjl + that.performInfo!.dcjl) / 100); + if (jl > Number(judgeUI.examMileage)) { + that.JudgeEnd() + } + judgeUI.jl = jl + judgeUI.laneSignal = that.performInfo!.lane + }) + + // 3.开始考试 + if (beginExamInfo) { + await examJudgeBeginExam(beginExamInfo); + } + dConsole.info(JudgeTag, '6.开始考试注册完成') + that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) + if (!judgeUI.singlePlay) { + that.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, that.context) + } + judgeUI.draw = true + // 处理单机泡轨迹模式 + if (isTrajectoryOpen) { + that.SingleMachineTrajectory(strArr) + return + } + }; + + async judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { + let examData: JudgeCallBackData = JSON.parse(strData); + const carzt = examData.carzt + const xmks = examData.xmks + const kf = examData.kf + const event = examData.event + const xmjs = examData.xmjs + const xmqx = examData.xmqx + const ksjs = examData.ksjs + const sound = examData.sound + const mndg = examData.mndg + const lane = examData.lane + const precast = examData.precast + const nongps = examData.nongps + //获取项目结束、项目开始代码 + const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm + const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh; + let artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] + const isManualProjectIn = artSubject3ProjectsCodesArr.includes(xmdm); + const examSubject = judgeUI.examSubject + switch (event) { + // 项目开始 + case 1: { + dConsole.info(JudgeTag, "项目开始") + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + project.type = '2'; + if (isManualProjectIn) { + //手动项目是否在进行中 + judgeUI.isManualProjectIn = true + } + if (xmdm == 41 && examSubject == '3') { + that.rmndg = 1 + } + 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; + that.xmmcSingleCode = xmmcSingleCode + that.xmmcEndCode = xmmcCode + that.xmdm = xmdm; + that.xmxh = xmxh; + judgeUI.isProjectIn = true + Reflect.set(judgeUI.projectsObj, xmdm, project) + Reflect.set(that.kmItems, xmmcCode || 0, kmItem) + break; + } + // 项目结束 + case 2: { + dConsole.info(JudgeTag, "项目结束") + 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' + }).length) > 0; + if (isManualProjectIn) { + judgeUI.isManualProjectIn = false + } + const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) + kmItem.status = 3; + //统计必考项目数量 + that.xmmcStr = '无'; + that.xmmcCode = ''; + that.xmdm = ''; + judgeUI.currentXmdm = undefined; + Reflect.set(judgeUI.projectsObj, xmdm, project) + Reflect.set(that.kmItems, xmmcCode, kmItem) + break; + } + // 扣分 + case 3: { + dConsole.info(JudgeTag, "项目扣分") + const thisKf = DeductionProjectConversion(`${kf.xmdm}_${kf.kfdm}`, judgeUI.markRuleListObj) + const kfObj: MarkRule = { + //扣分项目名称 + xmmcStr: CurrentProjectConversion(kf.xmdm, judgeUI.projectsObj), + xmdm: kf.xmdm + "", + //扣分描述 + desc: thisKf.desc, + //扣分分数 + score: thisKf.score, + // 扣分无锡所代码 + markcatalog: thisKf.markcatalog, + markserial: thisKf.markserial, + kfxh: thisKf.kfxh, + //扣分类型 + type: kf.type + } + dConsole.log(JudgeTag, "扣分组装", kfObj) + judgeUI.kfArr.push(kfObj) + dConsole.log(JudgeTag, "扣分类组装", judgeUI.kfArr) + judgeUI.totalScore += Number(thisKf?.score); + if (kf.xmdm != 20) { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm) + const type = project.type; + project.type = (type == '3' || type == '4') ? '4' : '5' + Reflect.set(judgeUI.projectsObj, kf.xmdm, project) + } + break; + } + // 考试状态 + case 4: { + that.carztStr = GetCarStatus(carzt); + break; + } + // 考试结束 + case 5: { + dConsole.info(JudgeTag, "考试结束") + that.ksjs = ksjs; + // await fileLog?.setExamJudgeData(JSON.stringify({ + // method: 'examJudgeEndExam' + // })) + dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ + method: 'examJudgeEndExam' + })) + break; + } + // 项目取消 + 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: { + dConsole.info(JudgeTag, '播放语音'); + this.goJudgeVoice(sound, that.avPlayer!) + break; + } + // 模拟灯光事件 + case 8: { + that.mndgStr = mndg + break; + } + // 车道和路段变化 + case 9: { + judgeUI.lane = lane + that.lane = lane; + break; + } + // 预进项目事件 + case 10: { + dConsole.info(JudgeTag, '预进项目'); + const xmdm = precast.xmdm + const xmxh = precast.xmxh + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + const xmmcCode: string = project.projectCodeCenter!; + const xmmcSingleCode: string = project.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: { + DetectingDifferences(nongps.type, that.avPlayer!) + break; + } + default: + break; + } + callBack({ + //项目名称 考车状态 扣分arr + xmmcStr: that.xmmcStr, carztStr: that.carztStr, kfArr: judgeUI.kfArr + }); + // TODO 语音播报 + this.changeExamStatus(event, xmdm, judgeUI.kfArr!, judgeUI, that); + // 更新ui + if (event == 1 || event == 2 || event == 3 || event == 6) { + judgeUI.projectsObj = JSON.parse(JSON.stringify(judgeUI.projectsObj)) + } + } + + async judgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { + 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.passingScore) + const jl = judgeUI.jl + if (that.isExamEnd) { + return + } + if (isManual) { + // 考试不合格 + await examJudgeEndExam() + that.isExamEnd = true + that.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 >= passingScore && !that.isEndTip) { + if (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 (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 (examSubject == '3' && param302 == 1) { + that.avPlayer?.playAudio([`voice/考试结束.mp3`]); + return + } + await examJudgeEndExam() + that.isExamEnd = true + return + } + + //成绩合格 + if (isAllProjectsEnd && totalScore >= passingScore && !that.isEndTip) { + if (examSubject == '2') { + await examJudgeEndExam() + that.isExamEnd = true + return + } + + //考试里程判断 + if (examSubject == '3' && jl < examMileage) { + return + } + + //考试合格自动退出 + if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) { + await examJudgeEndExam() + that.isExamEnd = true + return + } + + if (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 + } + } + } + } + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge/JudgeBusiness.ets b/entry/src/main/ets/pages/Judge/JudgeBusiness.ets index 2358942..fc0b651 100644 --- a/entry/src/main/ets/pages/Judge/JudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/JudgeBusiness.ets @@ -21,7 +21,7 @@ import { JudgeTag } from '../../config' import { examJudgeRealExam } from './JudgeSDKUtils' import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' import { PlcStrToJson, PlcStrToWXJson } from './utils' -import { BaseJudgeImpl, SetJudgeItem } from './Typing' +import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines' import { JudgePage } from '../Judge'; export default class JudgeBusiness { diff --git a/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets b/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets index d6d594b..4d49e0c 100644 --- a/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets @@ -21,7 +21,9 @@ import { SyssetConfig, SYSTEM_PARAM, Project, - ProjectInfos + ProjectInfos, + JudgeCallBackData, + KmItem } from '../../model'; import common from '@ohos.app.ability.common'; import { dConsole } from '../../utils/LogWorker'; @@ -36,16 +38,15 @@ import { import JudgeBusiness from './JudgeBusiness'; import { saveStartRecordVideo } from '../../utils/Video'; import router from '@ohos.router'; -import systemTime from '@ohos.systemTime'; import { GetModelData } from './utils'; -import { BaseJudgeImpl, GetSysSetResult } from './Typing'; +import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines'; import { GetSyncData } from '../../utils/table/Operation'; import promptAction from '@ohos.promptAction'; import { JudgePage } from '../Judge'; import systemDateTime from '@ohos.systemDateTime'; +import { testKm2Items, testKm3Items } from '../../mock'; - -export class LargeJudge implements BaseJudgeImpl { +export class LargeJudge extends BaseJudge implements BaseJudgeImpl { private mockLight: boolean = false private mode: number = 1 @@ -187,6 +188,7 @@ export class LargeJudge implements BaseJudgeImpl { let singlePlay: boolean = AppStorage.get("singlePlay")! let systemparmArr: Array = [] let projects: Array = [] + let examSubject: string = AppStorage.get('carInfo')!.examSubject! if (this.mode === 2) { totalScore = Number(currentParams.score) || 100 } @@ -336,13 +338,13 @@ export class LargeJudge implements BaseJudgeImpl { }); router.back(); } - // (examSubject === '2' ? testKm2Items : testKm3Items).forEach(item => { - // let project: ProjectInfo = Reflect.get(judgeUI.projectsCenterObj, item.code) - // Reflect.set(that.kmItems, item.code, { - // code: item.code, - // status: project === undefined ? 0 : (project.isEnd ? 3 : 1) - // }) - // }) + (examSubject === '2' ? testKm2Items : testKm3Items).forEach(item => { + let project: ProjectInfo = Reflect.get(judgeUI.projectsCenterObj, item.code) + Reflect.set(that.kmItems, item.code, { + code: item.code, + status: project === undefined ? 0 : (project.isEnd ? 3 : 1) + }) + }) return { totalScore, @@ -360,13 +362,7 @@ export class LargeJudge implements BaseJudgeImpl { } public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { - const name = judgeUI.name - const kssycs = judgeUI.kssycs - // 处理远程扣分使用 - const manualMarkRules = judgeUI.manualMarkRules - // 处理单机模式 const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen; - const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); const trajectoryPath = JudgeConfig.trajectoryPath; let strArr: string[] = []; if (isTrajectoryOpen) { @@ -374,70 +370,106 @@ export class LargeJudge implements BaseJudgeImpl { const str: string = await that.fileUtil.readFile(folderPath) strArr = str.split('\n') } - //日志回调 - dConsole.info(JudgeTag, '1.进入评判入口') - await examJudgeSetLogCallback(6, async (level: number, info: string, len: number) => { - dConsole.log(JudgeTag, '评判日志:' + info) - dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info) - }) - - dConsole.info(JudgeTag, '2.注册日志回调完成') - let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.GetJudgeInitData(judgeUI.context, judgeUI.markRuleListObj, judgeUI.carType, judgeUI.carName, judgeUI.systemparmArr, judgeUI.carinfoArr, judgeUI.examSubject, judgeUI.itemInfoObj!, judgeUI.judgeConfig, judgeUI.carlist, judgeUI.mapPointArr, judgeUI.mapPointItemArr); - //相关评判初始化只做一次 - if (!isJudgeInitBool) { - dConsole.log(JudgeTag, "评判初始化参数", initInfo) - await examJudgeInit(initInfo); - AppStorage.setOrCreate('isJudgeInitBool', true) - dConsole.info(JudgeTag, '4.评判初始化完成') - } - AppStorage.setOrCreate('isJudge', true) - // 2.评判过程回调 - await examJudgeSetRealExamCallback(async (strData: string, len: number) => { - // 评判回调日志 - dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData, strData) - dConsole.info(JudgeTag, '评判回调数据', strData) - await this.Judging(strData, callBack, judgeUI, that) - }) - await examJudgeSetPerformCallback(async (info: string) => { - dConsole.info('评判实时数据', info) - that.performInfo = JSON.parse(info) - const jl = Math.floor((that.performInfo!.qjjl + that.performInfo!.dcjl) / 100); - if (jl > Number(judgeUI.examMileage)) { - that.JudgeEnd() - } - judgeUI.jl = jl - judgeUI.laneSignal = that.performInfo!.lane - }) let beginExamInfo: JudgeBeginObj | undefined = undefined - // 3.开始考试 + if (isTrajectoryOpen) { beginExamInfo = JSON.parse(strArr[1]) beginExamInfo && (beginExamInfo.replay = 1) } else { beginExamInfo = await this.GetJudgeBeginData(judgeUI.projects, judgeUI.carType, judgeUI.kssycs, judgeUI.isDdxk, judgeUI.ddxkTime, judgeUI.projectsCenterObj, judgeUI.ddxkKsxmArr, judgeUI.ddxkKfArr, judgeUI.passingScore, judgeUI.wayno, judgeUI.name, judgeUI.lsh, judgeUI.idCard, that.isExam) } - if (beginExamInfo) { - await examJudgeBeginExam(beginExamInfo); - } - dConsole.info(JudgeTag, '6.开始考试注册完成') - that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) - if (!judgeUI.singlePlay) { - that.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, that.context) - } - judgeUI.draw = true - // 处理单机泡轨迹模式 - if (isTrajectoryOpen) { - that.SingleMachineTrajectory(strArr) - return - } + super.judgeStart(callBack, judgeUI, that, beginExamInfo!, initInfo) }; public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { + let examData: JudgeCallBackData = JSON.parse(strData); + const xmks = examData.xmks + const kf = examData.kf + const event = examData.event + const xmjs = examData.xmjs + const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm + + switch (event) { + // 项目开始 + case 1: { + if (this.mode === 2) { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + project.ykType = '2'; + Reflect.set(judgeUI.projectsObj, xmdm, project) + } + break; + } + // 项目结束 + case 2: { + if (this.mode === 2) { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + project.ykType = xmjs.xmhg === 0 ? '4' : '3'; + Reflect.set(judgeUI.projectsObj, xmdm, project) + } + break; + } + // 扣分 + case 3: { + if (kf.xmdm != 20) { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm) + const type = project.type; + if (this.mode === 2) { + project.ykType = (type === "3" || type === "4") ? '4' : '5'; + Reflect.set(judgeUI.projectsObj, kf.xmdm, project) + } + } + break; + } + // 考试状态 + case 4: { + break; + } + // 考试结束 + case 5: { + break; + } + // 项目取消 + case 6: { + if (this.mode === 2) { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + project.ykType = '1'; + Reflect.set(judgeUI.projectsObj, xmdm, project) + } + break; + } + // 语音播报和提示 + case 7: { + break; + } + // 模拟灯光事件 + case 8: { + break; + } + // 车道和路段变化 + case 9: { + break; + } + // 预进项目事件 + case 10: { + if (this.mode === 2) { + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) + project.ykType = '2'; + Reflect.set(judgeUI.projectsObj, xmdm, project) + } + } + // 差分事件 + case 11: { + break; + } + default: + break; + } + super.judging(strData, callBack, judgeUI, that) } public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { - + super.judgeEnd(judgeUI, that, isManual) }; } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets b/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets index 41afbaf..72b85ea 100644 --- a/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets @@ -46,7 +46,7 @@ import { GetCarStatus, GetModelData } from './utils'; -import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './Typing'; +import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines'; import { GetSyncData } from '../../utils/table/Operation'; import promptAction from '@ohos.promptAction'; import { JudgePage } from '../Judge'; @@ -315,12 +315,8 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl { } public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { - const name = judgeUI.name - const kssycs = judgeUI.kssycs - const manualMarkRules = judgeUI.manualMarkRules - // 处理单机模式 + const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen; - const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); const trajectoryPath = JudgeConfig.trajectoryPath; let strArr: string[] = []; if (isTrajectoryOpen) { @@ -328,361 +324,23 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl { const str: string = await that.fileUtil.readFile(folderPath) strArr = str.split('\n') } - //日志回调 - dConsole.info(JudgeTag, '1.进入评判入口') - await examJudgeSetLogCallback(6, async (level: number, info: string, len: number) => { - // dConsole.log(JudgeTag, '评判日志:' + info) - dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info) - }) - - dConsole.info(JudgeTag, '2.注册日志回调完成') - let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.GetJudgeInitData(judgeUI.context, judgeUI.markRuleListObj, judgeUI.carType, judgeUI.carName, judgeUI.systemparmArr, judgeUI.carinfoArr, judgeUI.examSubject, judgeUI.itemInfoObj!, judgeUI.judgeConfig, judgeUI.carlist, judgeUI.mapPointArr, judgeUI.mapPointItemArr); - //相关评判初始化只做一次 - if (!isJudgeInitBool) { - dConsole.info(JudgeTag, "评判初始化参数", initInfo) - let ret = await examJudgeInit(initInfo); - AppStorage.setOrCreate('isJudgeInitBool', true) - dConsole.info(JudgeTag, '4.评判初始化完成', ret) - } - AppStorage.setOrCreate('isJudge', true) - // 2.评判过程回调 - await examJudgeSetRealExamCallback(async (strData: string, len: number) => { - // 评判回调日志 - dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData, strData) - dConsole.info(JudgeTag, '评判回调数据', strData) - dConsole.info("lixiao", '评判回调数据', strData) - await this.Judging(strData, callBack, judgeUI, that) - }) - await examJudgeSetPerformCallback(async (info: string) => { - dConsole.info('评判实时数据', info) - that.performInfo = JSON.parse(info) - const jl = Math.floor((that.performInfo!.qjjl + that.performInfo!.dcjl) / 100); - if (jl > Number(judgeUI.examMileage)) { - that.JudgeEnd() - } - judgeUI.jl = jl - judgeUI.laneSignal = that.performInfo!.lane - }) let beginExamInfo: JudgeBeginObj | undefined = undefined - // 3.开始考试 + if (isTrajectoryOpen) { beginExamInfo = JSON.parse(strArr[1]) beginExamInfo && (beginExamInfo.replay = 1) } else { beginExamInfo = await this.GetJudgeBeginData(judgeUI.projects, judgeUI.carType, judgeUI.kssycs, judgeUI.isDdxk, judgeUI.ddxkTime, judgeUI.projectsCenterObj, judgeUI.ddxkKsxmArr, judgeUI.ddxkKfArr, judgeUI.passingScore, judgeUI.wayno, judgeUI.name, judgeUI.lsh, judgeUI.idCard, that.isExam) } - if (beginExamInfo) { - await examJudgeBeginExam(beginExamInfo); - } - dConsole.info(JudgeTag, '6.开始考试注册完成') - that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) - if (!judgeUI.singlePlay) { - that.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, that.context) - } - judgeUI.draw = true - // 处理单机泡轨迹模式 - if (isTrajectoryOpen) { - that.SingleMachineTrajectory(strArr) - return - } + super.judgeStart(callBack, judgeUI, that, beginExamInfo!, initInfo) }; public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { - let examData: JudgeCallBackData = JSON.parse(strData); - const carzt = examData.carzt - const xmks = examData.xmks - const kf = examData.kf - const event = examData.event - const xmjs = examData.xmjs - const xmqx = examData.xmqx - const ksjs = examData.ksjs - const sound = examData.sound - const mndg = examData.mndg - const lane = examData.lane - const precast = examData.precast - const nongps = examData.nongps - //获取项目结束、项目开始代码 - const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm - const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh; - let artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] - const isManualProjectIn = artSubject3ProjectsCodesArr.includes(xmdm); - const examSubject = judgeUI.examSubject - switch (event) { - // 项目开始 - case 1: { - dConsole.info(JudgeTag, "项目开始") - const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) - project.type = '2'; - if (isManualProjectIn) { - //手动项目是否在进行中 - judgeUI.isManualProjectIn = true - } - if (xmdm == 41 && examSubject == '3') { - that.rmndg = 1 - } - 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; - that.xmmcSingleCode = xmmcSingleCode - that.xmmcEndCode = xmmcCode - that.xmdm = xmdm; - that.xmxh = xmxh; - judgeUI.isProjectIn = true - Reflect.set(judgeUI.projectsObj, xmdm, project) - Reflect.set(that.kmItems, xmmcCode || 0, kmItem) - break; - } - // 项目结束 - case 2: { - dConsole.info(JudgeTag, "项目结束") - 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' - }).length) > 0; - if (isManualProjectIn) { - judgeUI.isManualProjectIn = false - } - const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode) - kmItem.status = 3; - //统计必考项目数量 - that.xmmcStr = '无'; - that.xmmcCode = ''; - that.xmdm = ''; - judgeUI.currentXmdm = undefined; - Reflect.set(judgeUI.projectsObj, xmdm, project) - Reflect.set(that.kmItems, xmmcCode, kmItem) - break; - } - // 扣分 - case 3: { - dConsole.info(JudgeTag, "项目扣分") - const thisKf = DeductionProjectConversion(`${kf.xmdm}_${kf.kfdm}`, judgeUI.markRuleListObj) - const kfObj: MarkRule = { - //扣分项目名称 - xmmcStr: CurrentProjectConversion(kf.xmdm, judgeUI.projectsObj), - xmdm: kf.xmdm + "", - //扣分描述 - desc: thisKf.desc, - //扣分分数 - score: thisKf.score, - // 扣分无锡所代码 - markcatalog: thisKf.markcatalog, - markserial: thisKf.markserial, - kfxh: thisKf.kfxh, - //扣分类型 - type: kf.type - } - dConsole.log(JudgeTag, "扣分组装", kfObj) - judgeUI.kfArr.push(kfObj) - dConsole.log(JudgeTag, "扣分类组装", judgeUI.kfArr) - judgeUI.totalScore += Number(thisKf?.score); - if (kf.xmdm != 20) { - const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm) - const type = project.type; - project.type = (type == '3' || type == '4') ? '4' : '5' - Reflect.set(judgeUI.projectsObj, kf.xmdm, project) - } - break; - } - // 考试状态 - case 4: { - that.carztStr = GetCarStatus(carzt); - break; - } - // 考试结束 - case 5: { - dConsole.info(JudgeTag, "考试结束") - that.ksjs = ksjs; - // await fileLog?.setExamJudgeData(JSON.stringify({ - // method: 'examJudgeEndExam' - // })) - dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({ - method: 'examJudgeEndExam' - })) - break; - } - // 项目取消 - 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: { - dConsole.info(JudgeTag, '播放语音'); - this.goJudgeVoice(sound, that.avPlayer!) - break; - } - // 模拟灯光事件 - case 8: { - that.mndgStr = mndg - break; - } - // 车道和路段变化 - case 9: { - judgeUI.lane = lane - that.lane = lane; - break; - } - // 预进项目事件 - case 10: { - dConsole.info(JudgeTag, '预进项目'); - const xmdm = precast.xmdm - const xmxh = precast.xmxh - const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) - const xmmcCode: string = project.projectCodeCenter!; - const xmmcSingleCode: string = project.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: { - DetectingDifferences(nongps.type, that.avPlayer!) - break; - } - default: - break; - } - callBack({ - //项目名称 考车状态 扣分arr - xmmcStr: that.xmmcStr, carztStr: that.carztStr, kfArr: judgeUI.kfArr - }); - // TODO 语音播报 - this.changeExamStatus(event, xmdm, judgeUI.kfArr!, judgeUI, that); - // 更新ui - if (event == 1 || event == 2 || event == 3 || event == 6) { - judgeUI.projectsObj = JSON.parse(JSON.stringify(judgeUI.projectsObj)) - } + super.judging(strData, callBack, judgeUI, that) } public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { - 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.passingScore) - const jl = judgeUI.jl - if (that.isExamEnd) { - return - } - if (isManual) { - // 考试不合格 - await examJudgeEndExam() - that.isExamEnd = true - that.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 >= passingScore && !that.isEndTip) { - if (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 (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 (examSubject == '3' && param302 == 1) { - that.avPlayer?.playAudio([`voice/考试结束.mp3`]); - return - } - await examJudgeEndExam() - that.isExamEnd = true - return - } - - //成绩合格 - if (isAllProjectsEnd && totalScore >= passingScore && !that.isEndTip) { - if (examSubject == '2') { - await examJudgeEndExam() - that.isExamEnd = true - return - } - - //考试里程判断 - if (examSubject == '3' && jl < examMileage) { - return - } - - //考试合格自动退出 - if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) { - await examJudgeEndExam() - that.isExamEnd = true - return - } - - if (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 - } - } - } - } + super.judgeEnd(judgeUI, that, isManual) }; }