合并公共代码

This commit is contained in:
lixiao 2025-10-13 16:41:53 +08:00
parent 7e75fef1a6
commit 0a2ec28599
6 changed files with 493 additions and 422 deletions

View File

@ -264,7 +264,8 @@ export const DefaultJudgeConfigData: DefaultJudgeConfigObj = {
//里程不够允许手工点靠边停车 //里程不够允许手工点靠边停车
param_387: '0', param_387: '0',
//监管模式有扣分续考0-否++1-是+把上次未考完的扣分带下来重新考试) //监管模式有扣分续考0-否++1-是+把上次未考完的扣分带下来重新考试)
param_432: '1' param_432: '1',
param_634: "1"
} }
//所有的科二 科目三项目 //所有的科二 科目三项目

View File

@ -309,6 +309,7 @@ export interface ProjectInfo {
isRequired?: boolean isRequired?: boolean
//项目状态:未做 正在做 及格 不及格 有扣分 //项目状态:未做 正在做 及格 不及格 有扣分
type?: '1' | '2' | '3' | '4' | '5' type?: '1' | '2' | '3' | '4' | '5'
ykType?: '1' | '2' | '3' | '4' | '5'
} }
/** 科目二项目代码 **/ /** 科目二项目代码 **/

View File

@ -1,8 +1,12 @@
import { import {
CarInfoType, CarInfoType,
JudgeBeginObj,
JudgeCallBackData,
JudgeConfigObj, JudgeConfigObj,
JudgeInitObj,
JudgeSound, JudgeSound,
JudgeUI, JudgeUI,
KmItem,
MarkRule, MarkRule,
ProcessDataEnumType, ProcessDataEnumType,
Project, Project,
@ -16,11 +20,21 @@ import { JudgePage } from "../Judge"
import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements' import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'
import { dConsole } from '../../utils/LogWorker' import { dConsole } from '../../utils/LogWorker'
import { JudgeConfig, JudgeTag } from '../../config' 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 { ProjectStart, UploadProgressPhoto } from './ProcessDataProcessing'
import { endRecordVideo } from '../../utils/Video' import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'
import router from '@ohos.router' import router from '@ohos.router'
import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation' import { GetSyncData, UpdateTableByArray } from '../../utils/table/Operation'
import { CurrentProjectConversion, DeductionProjectConversion, DetectingDifferences, GetCarStatus } from './utils'
export interface GetSysSetResult { export interface GetSysSetResult {
@ -291,15 +305,16 @@ export class BaseJudge {
Reflect.ownKeys(projectsObj).forEach(projectKey => { Reflect.ownKeys(projectsObj).forEach(projectKey => {
const projectObj: ProjectInfo = Reflect.get(projectsObj, projectKey) const projectObj: ProjectInfo = Reflect.get(projectsObj, projectKey)
const type = projectObj.type const type = projectObj.type
const ykType = projectObj.ykType
const isRequired = projectObj.isRequired const isRequired = projectObj.isRequired
allProjectNum += 1; allProjectNum += 1;
if (type == '3' || type == '4') { if (type == '3' || type == '4' || ykType === "3" || ykType === "4") {
allEndProjectsNum += 1; allEndProjectsNum += 1;
} }
if (isRequired) { if (isRequired) {
projectNum += 1; projectNum += 1;
if (type == '3' || type == '4') { if (type == '3' || type == '4' || ykType === "3" || ykType === "4") {
endProjectsNum += 1; endProjectsNum += 1;
} }
} }
@ -540,4 +555,368 @@ export class BaseJudge {
} }
return true 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<boolean>('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
}
}
}
}
}
} }

View File

@ -21,7 +21,7 @@ import { JudgeTag } from '../../config'
import { examJudgeRealExam } from './JudgeSDKUtils' import { examJudgeRealExam } from './JudgeSDKUtils'
import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker'
import { PlcStrToJson, PlcStrToWXJson } from './utils' import { PlcStrToJson, PlcStrToWXJson } from './utils'
import { BaseJudgeImpl, SetJudgeItem } from './Typing' import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines'
import { JudgePage } from '../Judge'; import { JudgePage } from '../Judge';
export default class JudgeBusiness { export default class JudgeBusiness {

View File

@ -21,7 +21,9 @@ import {
SyssetConfig, SyssetConfig,
SYSTEM_PARAM, SYSTEM_PARAM,
Project, Project,
ProjectInfos ProjectInfos,
JudgeCallBackData,
KmItem
} from '../../model'; } from '../../model';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import { dConsole } from '../../utils/LogWorker'; import { dConsole } from '../../utils/LogWorker';
@ -36,16 +38,15 @@ import {
import JudgeBusiness from './JudgeBusiness'; import JudgeBusiness from './JudgeBusiness';
import { saveStartRecordVideo } from '../../utils/Video'; import { saveStartRecordVideo } from '../../utils/Video';
import router from '@ohos.router'; import router from '@ohos.router';
import systemTime from '@ohos.systemTime';
import { GetModelData } from './utils'; import { GetModelData } from './utils';
import { BaseJudgeImpl, GetSysSetResult } from './Typing'; import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines';
import { GetSyncData } from '../../utils/table/Operation'; import { GetSyncData } from '../../utils/table/Operation';
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
import { JudgePage } from '../Judge'; import { JudgePage } from '../Judge';
import systemDateTime from '@ohos.systemDateTime'; import systemDateTime from '@ohos.systemDateTime';
import { testKm2Items, testKm3Items } from '../../mock';
export class LargeJudge extends BaseJudge implements BaseJudgeImpl {
export class LargeJudge implements BaseJudgeImpl {
private mockLight: boolean = false private mockLight: boolean = false
private mode: number = 1 private mode: number = 1
@ -187,6 +188,7 @@ export class LargeJudge implements BaseJudgeImpl {
let singlePlay: boolean = AppStorage.get("singlePlay")! let singlePlay: boolean = AppStorage.get("singlePlay")!
let systemparmArr: Array<SYSTEM_PARAM> = [] let systemparmArr: Array<SYSTEM_PARAM> = []
let projects: Array<Project> = [] let projects: Array<Project> = []
let examSubject: string = AppStorage.get<CarInfoType>('carInfo')!.examSubject!
if (this.mode === 2) { if (this.mode === 2) {
totalScore = Number(currentParams.score) || 100 totalScore = Number(currentParams.score) || 100
} }
@ -336,13 +338,13 @@ export class LargeJudge implements BaseJudgeImpl {
}); });
router.back(); router.back();
} }
// (examSubject === '2' ? testKm2Items : testKm3Items).forEach(item => { (examSubject === '2' ? testKm2Items : testKm3Items).forEach(item => {
// let project: ProjectInfo = Reflect.get(judgeUI.projectsCenterObj, item.code) let project: ProjectInfo = Reflect.get(judgeUI.projectsCenterObj, item.code)
// Reflect.set(that.kmItems, item.code, { Reflect.set(that.kmItems, item.code, {
// code: item.code, code: item.code,
// status: project === undefined ? 0 : (project.isEnd ? 3 : 1) status: project === undefined ? 0 : (project.isEnd ? 3 : 1)
// }) })
// }) })
return { return {
totalScore, totalScore,
@ -360,13 +362,7 @@ export class LargeJudge implements BaseJudgeImpl {
} }
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { 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 isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool');
const trajectoryPath = JudgeConfig.trajectoryPath; const trajectoryPath = JudgeConfig.trajectoryPath;
let strArr: string[] = []; let strArr: string[] = [];
if (isTrajectoryOpen) { if (isTrajectoryOpen) {
@ -374,70 +370,106 @@ export class LargeJudge implements BaseJudgeImpl {
const str: string = await that.fileUtil.readFile(folderPath) const str: string = await that.fileUtil.readFile(folderPath)
strArr = str.split('\n') 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); 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 let beginExamInfo: JudgeBeginObj | undefined = undefined
// 3.开始考试
if (isTrajectoryOpen) { if (isTrajectoryOpen) {
beginExamInfo = JSON.parse(strArr[1]) beginExamInfo = JSON.parse(strArr[1])
beginExamInfo && (beginExamInfo.replay = 1) beginExamInfo && (beginExamInfo.replay = 1)
} else { } 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) 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) { super.judgeStart(callBack, judgeUI, that, beginExamInfo!, initInfo)
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
}
}; };
public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { 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) { public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) {
super.judgeEnd(judgeUI, that, isManual)
}; };
} }

View File

@ -46,7 +46,7 @@ import {
GetCarStatus, GetCarStatus,
GetModelData GetModelData
} from './utils'; } from './utils';
import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './Typing'; import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines';
import { GetSyncData } from '../../utils/table/Operation'; import { GetSyncData } from '../../utils/table/Operation';
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
import { JudgePage } from '../Judge'; import { JudgePage } from '../Judge';
@ -315,12 +315,8 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
} }
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { 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 isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool');
const trajectoryPath = JudgeConfig.trajectoryPath; const trajectoryPath = JudgeConfig.trajectoryPath;
let strArr: string[] = []; let strArr: string[] = [];
if (isTrajectoryOpen) { if (isTrajectoryOpen) {
@ -328,361 +324,23 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
const str: string = await that.fileUtil.readFile(folderPath) const str: string = await that.fileUtil.readFile(folderPath)
strArr = str.split('\n') 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); 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 let beginExamInfo: JudgeBeginObj | undefined = undefined
// 3.开始考试
if (isTrajectoryOpen) { if (isTrajectoryOpen) {
beginExamInfo = JSON.parse(strArr[1]) beginExamInfo = JSON.parse(strArr[1])
beginExamInfo && (beginExamInfo.replay = 1) beginExamInfo && (beginExamInfo.replay = 1)
} else { } 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) 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) { super.judgeStart(callBack, judgeUI, that, beginExamInfo!, initInfo)
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
}
}; };
public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) { public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
let examData: JudgeCallBackData = JSON.parse(strData); super.judging(strData, callBack, judgeUI, that)
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))
}
} }
public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) {
const isAllProjectsEnd = judgeUI.isAllProjectsEnd super.judgeEnd(judgeUI, that, isManual)
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
}
}
}
}
}; };
} }