fix: 修复完善一些小问题

This commit is contained in:
wangzhongjie 2025-07-16 09:30:27 +08:00
parent 39bfed3beb
commit 46c9b8bd63
3 changed files with 262 additions and 247 deletions

View File

@ -31,6 +31,7 @@ export enum WorkerBackMessageType {
export interface LogWorkerMessage { export interface LogWorkerMessage {
type: WorkerMessageType; type: WorkerMessageType;
data?: string; data?: string;
studentDirName?: string
} }
//枚举 //枚举
@ -45,7 +46,8 @@ export enum WorkerMessageType {
ProcessDataInit = 'processDataInit', ProcessDataInit = 'processDataInit',
// 打开过程数据文件 // 打开过程数据文件
OpenProcessDataFile = 'openProcessDataFile', OpenProcessDataFile = 'openProcessDataFile',
// 初始化考试过程
ExamProcessInit = 'examProcessInit'
} }
export interface LogPathType { export interface LogPathType {

View File

@ -256,118 +256,120 @@ export default class Judge {
private isEndTip: boolean = false; private isEndTip: boolean = false;
private deductedPopShowTimer: number = 0; private deductedPopShowTimer: number = 0;
// 校验考试是否结束 // 校验考试是否结束
checkExamIsEnd = checkExamIsEnd = async (isManual?: boolean) => {
async (isManual?: boolean) => { dConsole.log(JudgeTag, "校验考试是否结束")
const judgeUI = this.judgeUI const judgeUI = this.judgeUI
const avPlayer = this.avPlayer const avPlayer = this.avPlayer
const isExamEnd = this.isExamEnd const isExamEnd = this.isExamEnd
const isEndTip = this.isEndTip const isEndTip = this.isEndTip
const isAllProjectsEnd = judgeUI.isAllProjectsEnd const isAllProjectsEnd = judgeUI.isAllProjectsEnd
const examSubject = judgeUI.examSubject const examSubject = judgeUI.examSubject
const singlePlay = judgeUI.singlePlay const singlePlay = judgeUI.singlePlay
const totalScore = Number(judgeUI.totalScore) const totalScore = Number(judgeUI.totalScore)
const judgeConfigObj = judgeUI.judgeConfigObj const judgeConfigObj = judgeUI.judgeConfigObj
const examMileage = Number(judgeUI.examMileage) const examMileage = Number(judgeUI.examMileage)
const passingScore = Number(judgeUI.examMileage) const passingScore = Number(judgeUI.examMileage)
const jl = judgeUI.jl const jl = judgeUI.jl
if (isExamEnd) { if (isExamEnd) {
return
}
//及格分
let passingGrade = passingScore
if (isManual) {
// 考试不合格
await examJudgeEndExam()
this.isExamEnd = true
this.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(',');
//单机模式 return
if (singlePlay) { }
dConsole.info(JudgeTag + ' 单机模式结束 => ', isAllProjectsEnd) //及格分
if (isAllProjectsEnd && jl >= examMileage) { let passingGrade = passingScore
//成绩合格 if (isManual) {
if (totalScore >= passingGrade && !isEndTip) { // 考试不合格
if (examSubject == '3' && (param342 == 0 || param342 == 2) && await examJudgeEndExam()
(param302 != 6 && param302 != 7 && param302 != 8)) { this.isExamEnd = true
if (param512[7] != 0) { this.isManual = true
clearTimeout(this.deductedPopShowTimer) } else {
avPlayer?.playAudio(['voice/综合评判.mp3']) const param302: number = Reflect.get(judgeConfigObj, '302')
this.judgeUI.isDeductedPopShow = true const param342: number = Reflect.get(judgeConfigObj, '342')
this.judgeUI.defaultTabIndex = 1 const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(',');
this.isEndTip = true
return //单机模式
} if (singlePlay) {
} else { dConsole.info(JudgeTag + ' 单机模式结束 => ', isAllProjectsEnd)
await examJudgeEndExam() if (isAllProjectsEnd && jl >= examMileage) {
this.isExamEnd = true //成绩合格
if (totalScore >= passingGrade && !isEndTip) {
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
(param302 != 6 && param302 != 7 && param302 != 8)) {
if (param512[7] != 0) {
clearTimeout(this.deductedPopShowTimer)
avPlayer?.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true
this.judgeUI.defaultTabIndex = 1
this.isEndTip = true
return return
} }
} else { } else {
if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) { await examJudgeEndExam()
await examJudgeEndExam() this.isExamEnd = true
this.isExamEnd = true
return
}
}
await examJudgeEndExam()
this.isExamEnd = true
}
} else {
//成绩不合格
if (totalScore < passingGrade) {
//科目三不合格报靠边停车
if (examSubject == '3' && param302 == 1) {
avPlayer?.playAudio([`voice/考试结束.mp3`]);
return return
} }
} else {
if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) {
await examJudgeEndExam()
this.isExamEnd = true
return
}
}
await examJudgeEndExam()
this.isExamEnd = true
}
} else {
//成绩不合格
if (totalScore < passingGrade) {
//科目三不合格报靠边停车
if (examSubject == '3' && param302 == 1) {
avPlayer?.playAudio([`voice/考试结束.mp3`]);
return
}
await examJudgeEndExam()
this.isExamEnd = true
return
}
//成绩合格
if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) {
if (examSubject == '2') {
await examJudgeEndExam() await examJudgeEndExam()
this.isExamEnd = true this.isExamEnd = true
return return
} }
//成绩合格 //考试里程判断
if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { if (examSubject == '3' && jl < examMileage) {
if (examSubject == '2') { return
await examJudgeEndExam() }
this.isExamEnd = true
return
}
//考试里程判断 //考试合格自动退出
if (examSubject == '3' && jl < examMileage) { if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) {
return await examJudgeEndExam()
} this.isExamEnd = true
return
}
//考试合格自动退出 if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) { (param302 != 6 && param302 != 7 && param302 != 8)) {
await examJudgeEndExam() if (param512[7] != 0) {
this.isExamEnd = true clearTimeout(this.deductedPopShowTimer)
return this.judgeUI.isDeductedPopShow = false
} avPlayer?.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true
if (examSubject == '3' && (param342 == 0 || param342 == 2) && this.judgeUI.defaultTabIndex = 1
(param302 != 6 && param302 != 7 && param302 != 8)) { this.isEndTip = true
if (param512[7] != 0) {
clearTimeout(this.deductedPopShowTimer)
this.judgeUI.isDeductedPopShow = false
avPlayer?.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true
this.judgeUI.defaultTabIndex = 1
this.isEndTip = true
}
} else {
await examJudgeEndExam()
this.isExamEnd = true
} }
} else {
await examJudgeEndExam()
this.isExamEnd = true
} }
} }
} }
} }
}
private ksjs?: JudgeKSJS private ksjs?: JudgeKSJS
private kfArr?: MarkRule[] private kfArr?: MarkRule[]
//所有的科目考试项目(大车&小车) //所有的科目考试项目(大车&小车)
@ -1059,162 +1061,161 @@ export default class Judge {
} }
} }
// 更改考试状态 // 更改考试状态
goVoiceAnnounce = goVoiceAnnounce = async (event: number, xmdm: number, kf: MarkRule[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => {
async (event: number, xmdm: number, kf: MarkRule[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => {
const beginProject = this.beginProject const beginProject = this.beginProject
const pointsDedute = this.pointsDedute const pointsDedute = this.pointsDedute
const endProject = this.endProject const endProject = this.endProject
const avPlayer = this.avPlayer const avPlayer = this.avPlayer
const uploadProgressPhoto = this.uploadProgressPhoto const uploadProgressPhoto = this.uploadProgressPhoto
const judgeTask = this.judgeTask const judgeTask = this.judgeTask
const handEndExam = this.handEndExam const handEndExam = this.handEndExam
const judgeUI = this.judgeUI const judgeUI = this.judgeUI
const checkExamIsEnd = this.checkExamIsEnd const checkExamIsEnd = this.checkExamIsEnd
const checkProjectIsStart = this.checkProjectIsStart const checkProjectIsStart = this.checkProjectIsStart
const lane = this.lane const lane = this.lane
const closeAllFiles = this.closeAllFiles const closeAllFiles = this.closeAllFiles
const projectsObj: object = judgeUI.projectsObj const projectsObj: object = judgeUI.projectsObj
const judgeConfigObj: object = judgeUI.judgeConfigObj const judgeConfigObj: object = judgeUI.judgeConfigObj
const examSubject = judgeUI.examSubject const examSubject = judgeUI.examSubject
const jl = judgeUI.jl const jl = judgeUI.jl
const isAllProjectsEnd = judgeUI.isAllProjectsEnd const isAllProjectsEnd = judgeUI.isAllProjectsEnd
const kfLen = kf.length; const kfLen = kf.length;
//不报语音的项目列表 //不报语音的项目列表
// const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') // const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',')
// const param611 = judgeConfigObj['611'] || ''; // const param611 = judgeConfigObj['611'] || '';
// const [f, s] = param611.split('/') // const [f, s] = param611.split('/')
switch (event) { switch (event) {
// 项目开始 // 项目开始
case 1: case 1:
const param512: JudgeConfigObj = (Reflect.get(judgeConfigObj, '512') || '').split(','); const param512: JudgeConfigObj = (Reflect.get(judgeConfigObj, '512') || '').split(',');
const project: ProjectInfo = Reflect.get(projectsObj, xmdm) const project: ProjectInfo = Reflect.get(projectsObj, xmdm)
const code = project.projectCodeCenter; const code = project.projectCodeCenter;
const isEnd = project.isEnd; const isEnd = project.isEnd;
// const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) // const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh)
// if (!ignoreVoiceCodeArr.includes(code)) { // if (!ignoreVoiceCodeArr.includes(code)) {
// if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){ // if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){
// //倒出入库、桩考\进项目语音控制 // //倒出入库、桩考\进项目语音控制
// }else{ // }else{
// kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) // kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true)
// } // }
// } // }
setTimeout(() => { setTimeout(() => {
if (Reflect.get(param512, 7) != 0) { if (Reflect.get(param512, 7) != 0) {
clearTimeout(this.deductedPopShowTimer) clearTimeout(this.deductedPopShowTimer)
this.judgeUI.isDeductedPopShow = true this.judgeUI.isDeductedPopShow = true
}
}, 200)
//项目已考不上传监管信息
if (!isEnd) {
judgeTask.addTask(async () => {
dConsole.info(JudgeTag, `项目开始-${xmdm}-${project.name}`)
await beginProject(xmdm)
}, {
isDelay: true
})
judgeTask.addTask(async () => {
dConsole.info(JudgeTag, `项目-${xmdm}-上传照片 start`)
await uploadProgressPhoto(xmdm)
}, {
isDelay: true
})
project.isUpload = true;
Reflect.set(this.judgeUI.projects, xmdm, project)
}
break;
// 项目结束
case 2: {
const project: ProjectInfo = Reflect.get(projectsObj, xmdm)
const endCode = project.projectCodeCenter;
const projectIsEnd = project.isEnd;
// const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh)
// if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) {
// endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`])
// }
const isStart = await this.checkProjectIsStart(xmdm, 1);
if (isStart) {
//项目结束了就不再生成数据
dConsole.info(JudgeTag + ' projectIsEnd =>', projectIsEnd)
if (!projectIsEnd) {
judgeTask.addTask(async () => {
dConsole.info(JudgeTag, `项目结束-${xmdm}-${project.name}`)
await endProject(xmdm);
this.xmmcSingleCode = '0';
this.xmmcEndCode = undefined;
}, {
isDelay: true
})
}
}
if (!this.judgeUI.isProjectIn) {
this.deductedPopShowTimer = setTimeout(() => {
this.judgeUI.isDeductedPopShow = false
}, (Reflect.get(param512!, 5) || 0) * 1000)
}
project.isEnd = true;
Reflect.set(this.judgeUI.projects, xmdm, project)
break;
}
// 扣分
case 3:
dConsole.info(JudgeTag, 'surenjun', '扣分开始')
//扣分时实时播报语音0-否+1-是)
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`])
}
const isStart = await checkProjectIsStart(Number(currentKf.xmdm), 2, currentKf);
if (isStart) {
await judgeTask.addTask(async () => {
dConsole.info(JudgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`)
await pointsDedute(Number(currentKf.xmdm), currentKf)
}, {
isDelay: true
})
}
break;
// 考车状态
case 4:
break
// 考试结束
case 5:
dConsole.info(JudgeTag, '考试结束')
//关闭录像
const singlePlay = AppStorage.get<boolean>('singlePlay')
if (!singlePlay && this.videoData) {
await endRecordVideo(this.videoData)
} }
}, 200)
//项目已考不上传监管信息
if (!isEnd) {
judgeTask.addTask(async () => { judgeTask.addTask(async () => {
dConsole.info(JudgeTag, '考试结束 start') dConsole.info(JudgeTag, `项目开始-${xmdm}-${project.name}`)
AppStorage.setOrCreate('isJudge', false) await beginProject(xmdm)
await handEndExam() }, {
isDelay: true
}) })
// TODO待修改 judgeTask.addTask(async () => {
// clearInterval(globalThis.judgeTimer) dConsole.info(JudgeTag, `项目-${xmdm}-上传照片 start`)
break await uploadProgressPhoto(xmdm)
default: }, {
break isDelay: true
} })
if (event == 2 || event == 3) { project.isUpload = true;
// setTimeout(() => { Reflect.set(this.judgeUI.projects, xmdm, project)
// this.judgeUI.kfArrScroller.scrollTo({ }
// yOffset: 999999, xOffset: 0 break;
// })
// }, 500) // 项目结束
//统计必考项目完成数量 case 2: {
await this.setCountItems(); const project: ProjectInfo = Reflect.get(projectsObj, xmdm)
await checkExamIsEnd() const endCode = project.projectCodeCenter;
const projectIsEnd = project.isEnd;
// const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh)
// if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) {
// endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`])
// }
const isStart = await this.checkProjectIsStart(xmdm, 1);
if (isStart) {
//项目结束了就不再生成数据
dConsole.info(JudgeTag + ' projectIsEnd =>', projectIsEnd)
if (!projectIsEnd) {
judgeTask.addTask(async () => {
dConsole.info(JudgeTag, `项目结束-${xmdm}-${project.name}`)
await endProject(xmdm);
this.xmmcSingleCode = '0';
this.xmmcEndCode = undefined;
}, {
isDelay: true
})
}
}
if (!this.judgeUI.isProjectIn) {
this.deductedPopShowTimer = setTimeout(() => {
this.judgeUI.isDeductedPopShow = false
}, (Reflect.get(param512!, 5) || 0) * 1000)
}
project.isEnd = true;
Reflect.set(this.judgeUI.projects, xmdm, project)
break;
} }
// 扣分
case 3:
dConsole.info(JudgeTag, 'surenjun', '扣分开始')
//扣分时实时播报语音0-否+1-是)
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`])
}
const isStart = await checkProjectIsStart(Number(currentKf.xmdm), 2, currentKf);
if (isStart) {
await judgeTask.addTask(async () => {
dConsole.info(JudgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`)
await pointsDedute(Number(currentKf.xmdm), currentKf)
}, {
isDelay: true
})
}
break;
// 考车状态
case 4:
break
// 考试结束
case 5:
dConsole.info(JudgeTag, '考试结束')
//关闭录像
const singlePlay = AppStorage.get<boolean>('singlePlay')
if (!singlePlay && this.videoData) {
await endRecordVideo(this.videoData)
}
judgeTask.addTask(async () => {
dConsole.info(JudgeTag, '考试结束 start')
AppStorage.setOrCreate('isJudge', false)
await handEndExam()
})
// TODO待修改
// clearInterval(globalThis.judgeTimer)
break
default:
break
} }
if (event == 2 || event == 3) {
// setTimeout(() => {
// this.judgeUI.kfArrScroller.scrollTo({
// yOffset: 999999, xOffset: 0
// })
// }, 500)
//统计必考项目完成数量
await this.setCountItems();
await checkExamIsEnd()
}
}
// 考试扣分 // 考试扣分
pointsDedute = async (ksxm: number, kf: MarkRule) => { pointsDedute = async (ksxm: number, kf: MarkRule) => {
const carInfo = AppStorage.get<CarInfoType>('carInfo')!; const carInfo = AppStorage.get<CarInfoType>('carInfo')!;
@ -1907,7 +1908,7 @@ export default class Judge {
// 2.评判过程回调 // 2.评判过程回调
await examJudgeSetRealExamCallback(async (strData: string, len: number) => { await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
// 评判回调日志 // 评判回调日志
// await fileLog?.setExamJudgeCallbackData(strData) await fileLog?.setExamJudgeCallbackData(strData)
dConsole.info(JudgeTag, '评判回调数据', strData) dConsole.info(JudgeTag, '评判回调数据', strData)
await this.handleRealExam(strData, callBack) await this.handleRealExam(strData, callBack)
}) })
@ -1963,7 +1964,6 @@ export default class Judge {
} }
// 处理实时udp里的plc信号 // 处理实时udp里的plc信号
DifferentialAndSignal.onMsg((data: string) => { DifferentialAndSignal.onMsg((data: string) => {
dConsole.info(JudgeTag, 'socketTag[PLC.UdpClient]', '收到udp回调数据')
const result: WorkerBackMessage = JSON.parse(data) const result: WorkerBackMessage = JSON.parse(data)
if (result.type === WorkerBackMessageType.ObtainUdpData) { if (result.type === WorkerBackMessageType.ObtainUdpData) {
handleUdp(result.data as string) handleUdp(result.data as string)

View File

@ -16,15 +16,18 @@ workerPort.onmessage = (e: MessageEvents) => {
let logFileFd: LogFileFd = {} let logFileFd: LogFileFd = {}
const result: LogWorkerMessage = JSON.parse(e.data); const result: LogWorkerMessage = JSON.parse(e.data);
if (result.type === WorkerMessageType.Init) { if (result.type === WorkerMessageType.Init) {
Init() InitLog()
} }
if (result.type === WorkerMessageType.OpenProcessDataFile) { if (result.type === WorkerMessageType.OpenProcessDataFile) {
OpenProcessDataFile(logPaths, logFileFd, result.data || "") OpenProcessDataFile(logPaths, logFileFd, result.data || "")
} }
if (result.type === WorkerMessageType.ExamProcessInit && result.studentDirName) {
InitExam(result.studentDirName)
}
} }
// 初始化 // 初始化日志
async function Init() { async function InitLog() {
// /mnt/hmdfs/100/account/device_view/local/files/duolun/logs/2024_10_12 // /mnt/hmdfs/100/account/device_view/local/files/duolun/logs/2024_10_12
// 创建duolun文件夹 /mnt/hmdfs/100/account/device_view/local/files/duolun // 创建duolun文件夹 /mnt/hmdfs/100/account/device_view/local/files/duolun
const basePath = GlobalConfig.commonFileWriteAddress; const basePath = GlobalConfig.commonFileWriteAddress;
@ -57,6 +60,16 @@ async function Init() {
} }
} }
// 初始化学员过程数据目录
async function InitExam(name: string) {
let date = dayTs().format("YYYY_MM_DD")
const path = `${GlobalConfig.commonFileWriteAddress}/logs/${date}/${name}`
const nameDirIsExit = await IsExit(path)
if (!nameDirIsExit) {
await CreateDir(path);
}
}
function OpenProcessDataFile(logPaths: LogPathType, logFileFd: LogFileFd, name: string) { function OpenProcessDataFile(logPaths: LogPathType, logFileFd: LogFileFd, name: string) {
} }