1963 lines
66 KiB
Plaintext
Raw Normal View History

2025-01-14 15:34:13 +08:00
import systemTime from '@ohos.systemDateTime';
import router from '@ohos.router';
import util from '@ohos.util';
import buffer from '@ohos.buffer';
2025-03-31 10:36:57 +08:00
import { testKm2Items, testKm3Items } from './dataTest/index';
import { KSJS } from './api/judgeSDK';
2025-01-14 15:34:13 +08:00
import VoiceAnnounce from './utils/voiceAnnouncements';
import FileModel from './utils/fileModel';
import FilePhoto from './utils/filePhoto';
import FileLog from './utils/fileLog';
import JudgeTask from './utils/judgeTask';
2025-04-09 09:28:18 +08:00
import { JudgeConfig } from './utils/judgeConfig';
2025-03-31 10:36:57 +08:00
import { LANE } from '../judgeSDK/api/judgeSDK.d';
import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation';
2025-01-14 15:34:13 +08:00
import { getCarStatus, getCenterProjectStatus, plcStrToJson, plcStrToWXJson, promptWxCode } from './utils/judgeCommon';
2025-01-14 15:34:13 +08:00
import {
examCalcGpsDistance,
examJudgeArtificialItem,
examJudgeArtificialMark,
examJudgeBeginExam,
examJudgeEndExam,
examJudgeInit,
examJudgeRealExam,
examJudgeSetLogCallback,
examJudgeSetPerformCallback,
examJudgeSetRealExamCallback,
examJudgeSoundEnd,
examJudgeVersion
2025-01-14 15:34:13 +08:00
} from './api/index';
2025-03-27 19:01:32 +08:00
2025-03-31 10:36:57 +08:00
import { uploadExamProgressData, writeObjectOut } from '../../api/judge';
import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video';
import common from '@ohos.app.ability.common';
2025-03-31 10:36:57 +08:00
import { convertGpsCoord2, deepClone } from './utils/Common';
import { GetCurrentTime } from '../../utils/Common';
import UsbService from '../../utils/USB';
2025-03-26 13:43:47 +08:00
import FileUtils from '../../utils/FileUtils';
2025-03-31 10:36:57 +08:00
import {
BaseInfoType,
CarInfoType,
CDSBInfo,
DrvexamType,
ExaminerInfoType,
ItemInfo,
JudgeBeginObj,
JudgeCallBackData,
JudgeConfigObj,
JudgeConfigObjKmItems,
JudgeEventKf,
JudgeInitObj,
2025-04-09 09:28:18 +08:00
JudgeKFXM,
JudgeKSJS,
JudgeKSXM,
JudgePerformInfo,
JudgeSound,
JudgeUI,
2025-04-09 09:28:18 +08:00
JudgeXMJS,
Km3JudgeInitConfig,
KmItem,
MarkRule,
Plc,
ProjectInfo,
RecordHandleType,
RegulatoryInterfaceParams,
RouteParamsType,
TKmItem,
User,
WR
2025-03-31 10:36:57 +08:00
} from '../../model';
import { DrivingDataStorage } from '../../utils/business/DrivingDataStorage';
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
const judgeTag = 'SURENJUN_JUDGE'
2025-01-14 15:34:13 +08:00
2025-03-27 19:01:32 +08:00
2025-03-31 10:36:57 +08:00
type GetKm3JudgeInitConfig = () => Promise<Km3JudgeInitConfig>
type GetgSbbm = (ksxm: number, xmxh: string) => string
type SendWriteObjectOut = (data: RegulatoryInterfaceParams, filePath: string) => Promise<WR>
type GetKfStr = (code: string) => MarkRule
type GetDqxmStr = (xmdm: number) => string
2025-03-27 19:01:32 +08:00
2025-03-28 16:54:29 +08:00
type TJudgeBeginObj = JudgeBeginObj
2025-03-31 10:36:57 +08:00
2025-01-20 08:50:40 +08:00
export default class Judge {
2025-03-31 10:36:57 +08:00
public plcStr: string
public judgeUI: JudgeUI
//获取科目三的评判初始化配置
getKm3JudgeInitConfig: GetKm3JudgeInitConfig = async () => {
return {
map_point: this.judgeUI.mapPointArr,
map_point_item: this.judgeUI.mapPointItemArr,
//科目三暂时为空
iteminfo: [],
roads: this.getModelData('km3/Roads.txt'),
sharps: this.getModelData('km3/Sharps.txt')
2024-07-31 13:47:40 +08:00
}
2025-03-31 10:36:57 +08:00
}
private context: common.UIAbilityContext
private fileLog: FileLog
//人工扣分
public setJudgeMark = async (itemno: string, serial: string, type = 1) => {
await examJudgeArtificialMark(Number(itemno), serial, type);
console.info(judgeTag, `进入人工扣分-${itemno}-${serial}`)
const str = JSON.stringify({
method: 'examJudgeArtificialMark',
itemno: Number(itemno),
serial,
type
})
await this.fileLog.setExamJudgeData(str)
console.info(judgeTag, `人工扣分-${itemno}-${serial}`)
}
//人工操作项目
public setJudgeItem = async (itemno: string, type: 1 | 2) => {
// const { fileLog } = this;
await examJudgeArtificialItem(Number(itemno), type);
const str = JSON.stringify({
method: 'examJudgeArtificialItem',
itemno: Number(itemno),
type
})
await this.fileLog.setExamJudgeData(str)
console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`)
}
private filePath: string
private totalScore: number
private prevJd: number = 0
private prevWd: number = 0
private dwztNum: number = 0
private folderPath: string
private modelPath: string
private avPlayer: VoiceAnnounce
// 处理特殊参数配置
handleSEP = async (code: number) => {
const judgeConfigObj = this.judgeUI.judgeConfigObj
const avPlayer = this.avPlayer
switch (code) {
//结束考试方式
case 306:
if (judgeConfigObj[code] == 5) {
//靠边停车
avPlayer.playAudio(['voice/406001.mp3'])
}
break;
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
}
2025-03-31 10:36:57 +08:00
private carztStr: string
private rmndg: 0 | 1
private mndgStr: string | undefined
// 模拟灯光
setMndg = async (mndgStr: string) => {
this.mndgStr = mndgStr
}
private xmmcStr: string
private xmmcCode: string
private xmmcSingleCode: string
private xmmcEndCode?: string
private xmdm: string | number
private xmxh: string
private fileModel: FileModel
private filePhoto: FilePhoto
// 过程照片拍照
getPhoto = async (empty?: boolean) => {
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay')
//单机模式返回空照片
if (singlePlay) {
return ''
} else {
const photoBase64 = await this.filePhoto.getPhoto();
console.info(judgeTag, '拍照完成')
return photoBase64
}
}
private usbService: UsbService
//是否是考试模式
private isExam: boolean
//考试是否结束了
private isExamEnd: boolean
// 是否发送udp
private isUdpEnd: boolean = false
//是否手动结束考试
private isManual: boolean
//UDP服务序列号
private serialIndex: number
private fileUtil: FileUtils
2025-01-20 08:50:40 +08:00
//上传无锡所过程数据
uploadProgressData = async () => {
2025-03-26 14:48:56 +08:00
const carInfo = AppStorage.get<CarInfoType>('carInfo')
2025-03-27 19:01:32 +08:00
const judgeUI = this.judgeUI
const fileUtil = this.fileUtil
const fileLog = this.fileLog
const carId = carInfo.carId
const examinationRoomId = carInfo.examinationRoomId
2025-01-20 08:50:40 +08:00
const folderPath = fileLog.folderPath
const base64 = new util.Base64();
const time = GetCurrentTime();
const endTime = GetCurrentTime(1)
2025-03-27 19:01:32 +08:00
let examDataBase64: string = ''
2025-01-20 08:50:40 +08:00
//TODO try catch报错待优化
2025-03-27 19:01:32 +08:00
const examDataStr: string = await this.fileUtil.readFile(`${folderPath}/wuxi_progress_data.txt`);
2025-01-20 08:50:40 +08:00
try {
let tempBuff = buffer.alloc(examDataStr.length, examDataStr)
let examData: Uint8Array = new Uint8Array(tempBuff.buffer)
examDataBase64 = base64.encodeToStringSync(examData)
} catch (e) {
console.info(judgeTag, JSON.stringify(e))
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
console.info(judgeTag, '过程数据文件上传 start')
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
try {
await uploadExamProgressData({
carId,
examinationRoomId,
type: 1,
2025-03-27 19:01:32 +08:00
time,
cardNo: judgeUI.idCard,
examData: examDataBase64,
examStartTime: judgeUI.startFullTime,
2025-01-20 08:50:40 +08:00
examEndTime: endTime,
})
} catch (e) {
console.info(judgeTag, '过程数据文件上传失败:' + JSON.stringify(e))
}
console.info(judgeTag, '过程数据文件上传 end')
}
2025-03-31 10:36:57 +08:00
private judgeTask: JudgeTask
// 检测扣分、结束项目时该项目是否开始
checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: JudgeEventKf) => {
if (xmdm == 20) {
return true
}
const judgeUI = this.judgeUI;
const judgeTask = this.judgeTask;
const projectsObj = this.judgeUI.projectsObj
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
const isUpload = currentProject.isUpload
//如果项目没有开始
console.info('surenjun isUpload=>', isUpload)
if (!isUpload) {
console.info(judgeTag, '项目补传开始')
//项目开始补传
judgeTask.addTask(async () => {
await this.beginProject(xmdm)
}, {
isDelay: true
})
judgeTask.addTask(async () => {
await this.uploadProgressPhoto(xmdm)
}, {
isDelay: true
})
currentProject.isUpload = true;
Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject)
//扣分补传
if (currentType == 2) {
judgeTask.addTask(async () => {
await this.pointsDedute(xmdm, kf)
}, {
isDelay: true
})
}
//扣分补传判断是否合格 不合格补传项目结束
if (currentType == 1 || (currentType == 2 && this.totalScore < judgeUI.passingScore)) {
judgeTask.addTask(async () => {
await this.endProject(xmdm)
}, {
isDelay: true
})
currentProject.isEnd = true;
Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject)
}
judgeTask.addTask(async () => {
this.checkExamIsEnd()
})
return false;
} else {
return true
}
}
2025-03-27 19:01:32 +08:00
private tempData: Plc
2025-01-20 08:50:40 +08:00
//实时计算gps经纬度距离
handDistance = async () => {
2025-03-27 19:01:32 +08:00
const dwzt = this.tempData.gps.dwzt;
const jdzt = this.tempData.gps.jdzt;
const tJD = convertGpsCoord2(this.tempData.gps.jd)
const tWD = convertGpsCoord2(this.tempData.gps.wd)
if (this.prevJd && dwzt == 4 && jdzt == 3) {
2025-01-20 08:50:40 +08:00
const distance = await examCalcGpsDistance({
2025-03-27 19:01:32 +08:00
jd1: this.prevJd,
wd1: this.prevWd,
2025-01-20 08:50:40 +08:00
jd2: tJD,
wd2: tWD,
2025-03-27 19:01:32 +08:00
h: (this.tempData.gps.hxj) || 1,
2025-01-20 08:50:40 +08:00
})
// const distanceClass = AppStorage.get<DistanceClass>('distanceClass')
// distanceClass?.setTimeData(Number(((distance / 100).toFixed(2))))
DrivingDataStorage.setDrivingProcessData(Number(((distance / 100).toFixed(2))))
2025-01-20 08:50:40 +08:00
}
this.prevJd = tJD;
this.prevWd = tWD;
}
2025-03-28 16:54:29 +08:00
private performInfo?: JudgePerformInfo
2025-01-20 08:50:40 +08:00
private isEndTip: boolean = false;
private deductedPopShowTimer: number = 0;
// 校验考试是否结束
checkExamIsEnd =
async (isManual?: boolean) => {
2025-03-27 19:01:32 +08:00
const judgeUI = this.judgeUI
const avPlayer = this.avPlayer
const isExamEnd = this.isExamEnd
const isEndTip = this.isEndTip
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.examMileage)
const jl = judgeUI.jl
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
if (isExamEnd) {
return
}
//及格分
let passingGrade = passingScore
if (isManual) {
// 考试不合格
await examJudgeEndExam()
this.isExamEnd = true
this.isManual = true
} else {
2025-03-31 10:36:57 +08:00
const param302: number = Reflect.get(judgeConfigObj, '302')
const param342: number = Reflect.get(judgeConfigObj, '342')
const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(',');
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
//单机模式
if (singlePlay) {
console.info(judgeTag + ' isAllProjectsEnd => ', isAllProjectsEnd)
if (isAllProjectsEnd && jl >= examMileage) {
//成绩合格
if (totalScore >= passingGrade && !isEndTip) {
2025-03-27 19:01:32 +08:00
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
2025-03-31 10:36:57 +08:00
(param302 != 6 && param302 != 7 && param302 != 8)) {
2025-01-20 08:50:40 +08:00
if (param512[7] != 0) {
clearTimeout(this.deductedPopShowTimer)
avPlayer.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true
this.judgeUI.defaultTabIndex = 1
this.isEndTip = true
return
}
} else {
await examJudgeEndExam()
this.isExamEnd = true
return
}
} else {
2025-03-27 19:01:32 +08:00
if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) {
2025-01-20 08:50:40 +08:00
await examJudgeEndExam()
this.isExamEnd = true
return
}
}
await examJudgeEndExam()
this.isExamEnd = true
}
} else {
//成绩不合格
if (totalScore < passingGrade) {
//科目三不合格报靠边停车
2025-03-27 19:01:32 +08:00
if (examSubject == '3' && param302 == 1) {
2025-01-20 08:50:40 +08:00
avPlayer.playAudio([`voice/考试结束.mp3`]);
return
}
await examJudgeEndExam()
this.isExamEnd = true
return
}
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
//成绩合格
if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) {
2025-03-27 19:01:32 +08:00
if (examSubject == '2') {
2025-01-20 08:50:40 +08:00
await examJudgeEndExam()
this.isExamEnd = true
return
}
//考试里程判断
2025-03-27 19:01:32 +08:00
if (examSubject == '3' && jl < examMileage) {
2025-01-20 08:50:40 +08:00
return
}
//考试合格自动退出
2025-03-27 19:01:32 +08:00
if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) {
2025-01-20 08:50:40 +08:00
await examJudgeEndExam()
this.isExamEnd = true
return
}
2025-03-27 19:01:32 +08:00
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
(param302 != 6 && param302 != 7 && param302 != 8)) {
2025-01-20 08:50:40 +08:00
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
}
}
}
}
}
2025-04-09 09:28:18 +08:00
private ksjs: JudgeKSJS
2025-03-28 16:54:29 +08:00
private kfArr: JudgeEventKf[]
2025-01-20 08:50:40 +08:00
//所有的科目考试项目(大车&小车)
2025-04-09 09:28:18 +08:00
private kmItems: JudgeConfigObjKmItems
2025-03-27 19:01:32 +08:00
private plcData: Plc
2025-01-20 08:50:40 +08:00
// 获取plc数据
getPlcData = async (plc: string) => {
2025-03-27 19:01:32 +08:00
await this.fileLog.setPlcProgressData(plc)
2025-01-20 08:50:40 +08:00
//plc字符串转化成评判初始化数据
const tempData = await plcStrToJson(plc);
//模拟灯光回放时刻
2025-03-27 19:01:32 +08:00
tempData.sensor.rmndg = this.rmndg;
2025-01-20 08:50:40 +08:00
//模拟灯灯光灯光项目
2025-03-27 19:01:32 +08:00
tempData.sensor.mndg = this.mndgStr;
2025-01-20 08:50:40 +08:00
//plc字符串转化成无锡所过程数据
const wuXiDataStr = await plcStrToWXJson(plc)
this.plcData = tempData
2025-03-27 19:01:32 +08:00
await this.fileLog.setExamJudgeWuxiProgressData(wuXiDataStr)
2025-01-20 08:50:40 +08:00
this.tempData = tempData
this.plcStr = plc;
this.mndgStr = '';
this.rmndg = 0;
AppStorage.setOrCreate('msgStr', plc)
2025-01-20 08:50:40 +08:00
return tempData
}
// 处理udp plc信号
handleUdp = async (msg: string) => {
console.info('plc信号', msg)
const stachArr = msg.split(',')
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
return
}
const plcData = await this.getPlcData(msg);
// 4.过程数据
await this.fileLog.setExamJudgeData(JSON.stringify(plcData))
//检测到有无锡所设备接入,需要发送特定的数据,供检测
// if (this.usbService.isWXUSBDevice) {
// const str = await senorToWXDataStr(msg);
// this.usbService.sendUSB(str)
// }
const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350')
this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + ''
this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + ''
//TODO 暂时关闭差分检测异常
// await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt);
if (!this.isExamEnd) {
await examJudgeRealExam(plcData)
}
let udpIndex = AppStorage.get<number>('udpIndex');
if (udpIndex % 5 === 0 && !this.isUdpEnd) {
// TODO UPD缺失
// const judgeUdp = globalThis.judgeUdp
// const bytes = await this.getMessageHeartbeat(this.isExamEnd);
// judgeUdp.send(bytes)
}
AppStorage.setOrCreate('udpIndex', udpIndex++)
}
2025-01-20 08:50:40 +08:00
// 处理轨迹plc信号
2025-03-31 10:36:57 +08:00
handleTrajectoryUdp = async (strArr: string[]) => {
// const { fileLog, setJudgeItem, setJudgeMark, endExam } = this;
2025-01-20 08:50:40 +08:00
let num = 2;
const judgeTimer = setInterval(async () => {
const msgStr = strArr[num];
if (msgStr == '') {
console.info(judgeTag, '模拟数据考试结束')
clearInterval(judgeTimer)
this.checkExamIsEnd(true)
return
}
2025-03-31 10:36:57 +08:00
const msg: Plc = JSON.parse(strArr[num]);
2025-01-20 08:50:40 +08:00
num++
// 4.过程数据
this.tempData = msg
this.judgeUI.isDwztRight = (msg?.gps?.dwzt == 4 && msg?.gps?.jdzt == 3);
this.judgeUI.sd = Math.floor(msg?.gps?.sd * 1.852) + '';
this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + ''
this.plcData = msg
// this.judgeUI.isDwztRight = msg.gps.dwzt == 4;
AppStorage.setOrCreate('msgStr', '')
2025-01-20 08:50:40 +08:00
if (msg.method === 'examJudgeArtificialItem') {
this.setJudgeItem(msg.itemno, msg.type)
2025-01-20 08:50:40 +08:00
}
if (msg.method === 'examJudgeArtificialMark') {
this.setJudgeItem(msg.itemno, msg.serial)
2025-01-20 08:50:40 +08:00
}
await examJudgeRealExam(msg)
// const bytes = await this.getMessageHeartbeat();
// bytes && globalThis.judgeUdp.send(bytes)
2025-01-20 08:50:40 +08:00
}, 200)
// TODO 定时器缺失
// globalThis.judgeTimer = judgeTimer;
2025-01-20 08:50:40 +08:00
}
//本地轨迹回放地址
private trajectoryPath: string
//当前科目二的考试项目
2025-03-31 10:36:57 +08:00
// private currentKm2ItemsObj: any
2025-01-20 08:50:40 +08:00
private isTrajectoryOpen: boolean;
// 调代理接口是否断网了
private isJudgeDisConnect: boolean;
2025-03-31 10:36:57 +08:00
// 断网数据补传
uploadDisConnectData = async () => {
if (!this.isJudgeDisConnect) {
return
}
const folderPath = this.fileLog.folderPath
const examDataStr = await this.fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`);
const examDataArr = examDataStr.split('\n');
for (let examDataStr of examDataArr) {
const code = await writeObjectOut(JSON.parse(examDataStr));
}
}
2025-01-20 08:50:40 +08:00
// 项目开始接口同步
2025-03-31 10:36:57 +08:00
beginProject = async (ksxm: number) => {
2025-03-26 14:48:56 +08:00
const carInfo = AppStorage.get<CarInfoType>('carInfo');
2025-03-31 10:36:57 +08:00
const judgeUI = this.judgeUI
const time = GetCurrentTime();
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm)
2025-03-27 19:01:32 +08:00
const sbxh = this.getSbbm(ksxm, this.xmxh)
2025-03-31 10:36:57 +08:00
const drvexam: DrvexamType = {
lsh: judgeUI.lsh,
2025-03-27 19:01:32 +08:00
kskm: carInfo.examSubject,
sfzmhm: judgeUI.idCard,
ksxm: project.projectCodeCenter,
sbxh,
ksxl: judgeUI.xldm,
kchp: encodeURI(carInfo.plateNo),
ksdd: encodeURI(judgeUI.ksdd),
kslx: encodeURI(judgeUI.kslx) || '',
kssj: time
}
2025-03-31 10:36:57 +08:00
const data: RegulatoryInterfaceParams = {
2025-01-20 08:50:40 +08:00
//系统类别 接口序列号 接口标识
2025-02-11 09:18:16 +08:00
xtlb: '17',
2025-03-27 19:01:32 +08:00
jkxlh: judgeUI.serialNumber,
2025-02-11 09:18:16 +08:00
jkid: '17C52',
2025-03-27 19:01:32 +08:00
drvexam
2025-01-20 08:50:40 +08:00
}
2025-03-31 10:36:57 +08:00
const temp: WR = await this.sendWriteObjectOut(data, this.filePath)
2025-01-20 08:50:40 +08:00
console.info(judgeTag, '项目开始 end')
2025-03-27 19:01:32 +08:00
if (temp.code === 2300007) {
2025-01-20 08:50:40 +08:00
this.isJudgeDisConnect = true;
}
2025-03-27 19:01:32 +08:00
promptWxCode('17C52', temp.code)
2025-01-20 08:50:40 +08:00
}
// 项目结束接口同步
2025-03-31 10:36:57 +08:00
endProject = async (ksxm: number) => {
2025-03-26 14:48:56 +08:00
const carInfo = AppStorage.get<CarInfoType>('carInfo');
2025-03-28 16:54:29 +08:00
const judgeUI = this.judgeUI;
const time = GetCurrentTime();
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm)
2025-03-28 16:54:29 +08:00
const sbxh = judgeUI.examSubject == '3' ? undefined : this.getSbbm(ksxm, this.xmxh)
2025-01-20 08:50:40 +08:00
2025-03-31 10:36:57 +08:00
const drvexam: DrvexamType = {
lsh: judgeUI.lsh,
2025-03-28 16:54:29 +08:00
kskm: carInfo.examSubject,
sfzmhm: judgeUI.idCard,
ksxm: project.projectCodeCenter,
sbxh,
//TODO 操作类型 1:正常 0:撤销该考试记录
czlx: '1',
ksxl: judgeUI.xldm,
kchp: encodeURI(carInfo.plateNo),
ksdd: encodeURI(judgeUI.ksdd),
kslx: encodeURI(judgeUI.kslx) || '',
jssj: time
}
2025-03-31 10:36:57 +08:00
const data: RegulatoryInterfaceParams = {
2025-02-11 09:18:16 +08:00
xtlb: '17',
2025-03-28 16:54:29 +08:00
jkxlh: judgeUI.serialNumber,
2025-02-11 09:18:16 +08:00
jkid: '17C55',
2025-03-28 16:54:29 +08:00
drvexam
2025-01-20 08:50:40 +08:00
}
2025-03-31 10:36:57 +08:00
const temp: WR = await this.sendWriteObjectOut(data, this.filePath)
2025-03-28 16:54:29 +08:00
if (temp.code === 2300007) {
2025-01-20 08:50:40 +08:00
this.isJudgeDisConnect = true;
}
console.info(judgeTag, '项目结束 end')
2025-03-28 16:54:29 +08:00
promptWxCode('17C55', temp.code)
2025-01-20 08:50:40 +08:00
}
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
private lane: LANE = {
road: '', num: 0, count: 0
}
private videoData: RecordHandleType
private disConnectNum: number = 0;
//调用监管接口
sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => {
const temp = await writeObjectOut(data, filePath);
console.log("wzj", JSON.stringify(temp))
//断网&网络超时次数计算
if (temp.code == 2300007 || temp.code == 2300028) {
this.disConnectNum += 1;
if (this.disConnectNum < 5) {
return await this.sendWriteObjectOut(data, filePath)
}
}
if (this.disConnectNum >= 5) {
console.info('surenjun', '123')
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
this.judgeUI.disConnectErrorOpen = true
}
this.disConnectNum = 0
return temp
}
// 考试过程照片
uploadProgressPhoto = async (ksxm: number) => {
const time = GetCurrentTime();
const judgeUI = this.judgeUI
const plcData = this.plcData
const photoBase64 = await this.getPhoto();
const carInfo = AppStorage.get<CarInfoType>('carInfo');
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm)
const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305')
const drvexam: DrvexamType = {
lsh: judgeUI.lsh,
kskm: carInfo.examSubject,
ksxm: project.projectCodeCenter,
sfzmhm: judgeUI.idCard,
kchp: encodeURI(carInfo.plateNo),
zpsj: time,
zp: photoBase64,
cs: Math.floor((judgeConfig_305 == 0 ? plcData.gps.sd : plcData.sensor.cs) * 1.852),
ksdd: encodeURI(judgeUI.ksdd)
}
const data: RegulatoryInterfaceParams = {
xtlb: '17',
jkxlh: judgeUI.serialNumber,
jkid: '17C54',
drvexam
};
const temp: WR = await this.sendWriteObjectOut(data, this.filePath);
if (temp.code === 2300007) {
this.isJudgeDisConnect = true
}
promptWxCode('17C54', temp.code)
console.info(judgeTag, '上传照片 end')
}
2025-01-20 08:50:40 +08:00
2025-03-27 19:01:32 +08:00
constructor(judgeUI: JudgeUI) {
2025-01-20 08:50:40 +08:00
this.serialIndex = 1;
this.judgeUI = judgeUI
//语音播放工具
this.avPlayer = new VoiceAnnounce(this.context);
2025-01-20 08:50:40 +08:00
//模型工具
this.fileModel = new FileModel(judgeUI.context);
//文件工具
2025-03-26 13:43:47 +08:00
this.fileUtil = new FileUtils(judgeUI.context)
2025-01-20 08:50:40 +08:00
this.judgeTask = new JudgeTask()
this.usbService = new UsbService();
this.filePhoto = new FilePhoto(judgeUI.context);
this.kfArr = judgeUI.kfArr
this.xmmcStr = '';
this.xmmcCode = '';
this.xmmcEndCode = undefined;
this.carztStr = '';
2025-03-28 16:54:29 +08:00
this.kmItems = {};
2025-01-20 08:50:40 +08:00
// 考试回放配置
2025-04-09 09:28:18 +08:00
this.isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
this.modelPath = JudgeConfig.modelPath;
this.trajectoryPath = JudgeConfig.trajectoryPath;
2025-01-20 08:50:40 +08:00
this.isExam = !this.judgeUI.singlePlay;
2025-03-28 16:54:29 +08:00
(judgeUI.examSubject == '2' ? testKm2Items : testKm3Items).forEach(item => {
2025-03-31 10:36:57 +08:00
const projectCenterObj: ProjectInfo = Reflect.get(judgeUI.projectsCenterObj, item.code)
2025-03-28 16:54:29 +08:00
2025-03-31 10:36:57 +08:00
const currentItem: KmItem = Reflect.get(this.kmItems, item.code)
currentItem.code = item.code
currentItem.status = projectCenterObj === undefined ? 0 : (projectCenterObj.isEnd ? 3 : 1)
Reflect.set(this.kmItems, item.code, currentItem)
2025-01-14 15:34:13 +08:00
})
2025-03-28 16:54:29 +08:00
console.info(judgeTag + 'testKmItems', JSON.stringify(this.kmItems))
2025-01-20 08:50:40 +08:00
this.isExamEnd = false;
2024-07-05 09:08:17 +08:00
}
2025-01-20 08:50:40 +08:00
public async onJudgeFn(fn: Function) {
await this.judging(fn)
2025-01-14 15:34:13 +08:00
}
// 获取评判初始化数据
getJudgeInitData = async () => {
2025-03-26 14:48:56 +08:00
const carInfo = AppStorage.get<CarInfoType>('carInfo');
2025-01-14 15:34:13 +08:00
const judgeUI = this.judgeUI
2025-03-28 16:54:29 +08:00
const projectsObj = judgeUI.projectsObj
const itemInfoObj = judgeUI.itemInfoObj
const markRuleListObj = judgeUI.markRuleListObj
const carType = judgeUI.carType
const carName = judgeUI.carName
const systemparmArr = judgeUI.systemparmArr
const carinfoArr = judgeUI.carinfoArr
2025-03-31 10:36:57 +08:00
const examType = carInfo.examSubject == '2' ? 'km2' : 'km3'
2025-03-28 16:54:29 +08:00
2025-03-31 10:36:57 +08:00
let allitems: ItemInfo[] = [];
2025-03-28 16:54:29 +08:00
if (judgeUI.examSubject == '2') {
2025-01-14 15:34:13 +08:00
allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => {
2025-03-31 10:36:57 +08:00
const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey);
2025-03-28 16:54:29 +08:00
const model = this.getModelData(`${examType}/${cdsb.modelKey}.txt`)
2025-03-31 10:36:57 +08:00
const temp: ItemInfo = {
xmdm: cdsb.xmdm, xmxh: cdsb.xmxh, model
}
2025-03-28 16:54:29 +08:00
return temp
2025-01-14 15:34:13 +08:00
})
}
2025-03-28 16:54:29 +08:00
2025-01-14 15:34:13 +08:00
//获取版本号
2025-03-31 10:36:57 +08:00
const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => {
const current: MarkRule = Reflect.get(markRuleListObj, ruleKey)
2025-03-28 16:54:29 +08:00
return current
})
2025-03-31 10:36:57 +08:00
const initInfo: JudgeInitObj = {
sdkver: await examJudgeVersion(),
2025-03-26 14:48:56 +08:00
appver: AppStorage.get<BaseInfoType>('baseInfo').version,
2025-03-28 16:54:29 +08:00
kskm: Number(carInfo.examSubject),
kchp: carInfo.plateNo,
kchm: Number(carInfo.carId),
2025-01-14 15:34:13 +08:00
kscx: carType,
cxcode: '1',
name: carName,
2025-03-28 16:54:29 +08:00
carmodel: this.getModelData(`${examType}/${carType}.txt`),
2025-01-14 15:34:13 +08:00
allitems,
iteminfo: [],
systemparm: systemparmArr,
2025-03-28 16:54:29 +08:00
mark,
2025-01-14 15:34:13 +08:00
sysset: judgeUI.judgeConfig,
itemInfoObj,
2025-01-20 08:50:40 +08:00
carlist: judgeUI.carlist,
2025-01-14 15:34:13 +08:00
carinfo: carinfoArr,
};
2025-03-31 10:36:57 +08:00
let km3Config: Km3JudgeInitConfig = {}
2025-03-28 16:54:29 +08:00
if (judgeUI.examSubject == '3') {
km3Config = await this.getKm3JudgeInitConfig();
initInfo.map_point = km3Config.map_point
initInfo.map_point_item = km3Config.map_point_item
initInfo.iteminfo = km3Config.iteminfo
initInfo.roads = km3Config.roads
initInfo.sharps = km3Config.sharps
2025-01-14 15:34:13 +08:00
}
// 获取科目三的评判配置
console.info(judgeTag, '3.获取评判初始化数据完成')
2025-03-28 16:54:29 +08:00
return initInfo
2025-01-14 15:34:13 +08:00
}
// 获取开始考试数据
getJudgeBeginData = async () => {
2025-03-28 16:54:29 +08:00
const examinerInfo = AppStorage.get<ExaminerInfoType>('examinerInfo')
const code = examinerInfo.code
const examinerName = examinerInfo.name
let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
const sczb = currentParams.sczb;
2025-03-31 10:36:57 +08:00
const kfdm = currentParams.kfdm;
2025-03-28 16:54:29 +08:00
const isExam = this.isExam;
2025-01-14 15:34:13 +08:00
const judgeUI = this.judgeUI
2025-03-28 16:54:29 +08:00
const projects = judgeUI.projects
const carType = judgeUI.carType
const kssycs = judgeUI.kssycs
const isDdxk = judgeUI.isDdxk
const ddxkTime = judgeUI.ddxkTime
const projectsCenterObj = judgeUI.projectsCenterObj
const ddxkKsxmArr = judgeUI.ddxkKsxmArr
const ddxkKfArr = judgeUI.ddxkKfArr
const passingScore = judgeUI.passingScore
2025-04-09 09:28:18 +08:00
const ksxm: JudgeKSXM[] = projects.map(project => {
const temp: JudgeKSXM = {
2025-03-31 10:36:57 +08:00
xmdm: Number(project.projectCode), xmxh: ''
}
2025-03-28 16:54:29 +08:00
return temp
})
2025-03-31 10:36:57 +08:00
const ykxm: number[] = (ddxkKsxmArr?.map(projectCenterCode => {
const currentProject: ProjectInfo = Reflect.get(projectsCenterObj, projectCenterCode)
2025-03-28 16:54:29 +08:00
return Number(currentProject.projectCode)
})) || [];
2025-04-09 09:28:18 +08:00
const kfxm: JudgeKFXM[] = isDdxk ? (ddxkKfArr?.map(kf => {
2025-03-31 10:36:57 +08:00
return {
xmdm: Number(kf.split(',')[0]), kfdm: kf.split(',')[1]
2025-04-09 09:28:18 +08:00
} as JudgeKFXM
2025-03-28 16:54:29 +08:00
})) : []
2025-03-31 10:36:57 +08:00
const beginInfo: JudgeBeginObj = {
2025-01-14 15:34:13 +08:00
kgid: '012',
kgxm: decodeURI(examinerName || ''),
exam: isExam ? 1 : 0,
//是否回放
replay: 0,
//生成的轨迹文件
track: '',
xm: judgeUI.name,
sex: 0,
kslsh: judgeUI.lsh,
sfzmhm: judgeUI.idCard,
ksyy: '',
kscx: carType,
2025-01-20 08:50:40 +08:00
kkcs: Number(kssycs) || 2,
2025-01-14 15:34:13 +08:00
sfyk: 0,
ykkkcs: 1,
2025-03-28 16:54:29 +08:00
wayno: Number(judgeUI.wayno),
2025-01-14 15:34:13 +08:00
czlx: 0,
2025-03-31 10:36:57 +08:00
kskssj: await systemTime.getCurrentTime(),
2025-03-28 16:54:29 +08:00
passing: Number(passingScore),
ksxm,
2025-01-14 15:34:13 +08:00
//断点续考
ddxk: isDdxk ? 1 : 0,
ddkssj: ddxkTime || 0,
2025-03-28 16:54:29 +08:00
ykxm,
kfxm,
2025-01-14 15:34:13 +08:00
//TODO 已考里程待修改
yklc: 0,
special: [],
2025-03-28 16:54:29 +08:00
sczb: (sczb === undefined || sczb == '0') ? 0 : 1,
2025-01-14 15:34:13 +08:00
sczbkf: kfdm,
dmndg: false,
mfxx: false,
mfxxn: false
}
console.info(judgeTag, '5.获取开始考试数据完成')
return beginInfo
}
//处理评判过程回调
2025-03-31 10:36:57 +08:00
handleRealExam = async (strData: string, callBack: Function) => {
2025-03-28 16:54:29 +08:00
let examData: JudgeCallBackData = JSON.parse(strData);
const getDqxmStr = this.getDqxmStr;
const getKfStr = this.getKfStr;
const goJudgeVoice = this.goJudgeVoice;
const setMndg = this.setMndg;
const avPlayer = this.avPlayer;
const fileLog = this.fileLog;
const judgeUI = this.judgeUI;
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
2025-01-14 15:34:13 +08:00
//获取项目结束、项目开始代码
const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm
const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh;
const isManualProjectIn = this.artSubject3ProjectsCodesArr.includes(xmdm);
2025-03-28 16:54:29 +08:00
const examSubject = this.judgeUI.examSubject
const projects = this.judgeUI.projects
const judgeConfigObj = this.judgeUI.judgeConfigObj
2025-01-14 15:34:13 +08:00
switch (event) {
//项目开始
case 1:
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
2025-03-28 16:54:29 +08:00
project.type = '2';
2025-01-14 15:34:13 +08:00
if (isManualProjectIn) {
//手动项目是否在进行中
this.judgeUI.isManualProjectIn = true
}
2025-03-28 16:54:29 +08:00
if (xmdm == 41 && examSubject == '3') {
2025-01-14 15:34:13 +08:00
this.rmndg = 1
}
this.judgeUI.currentXmdm = xmdm;
2025-03-28 16:54:29 +08:00
const xmmcStr = project.name;
const xmmcCode = project.projectCodeCenter;
const xmmcSingleCode = project.projectCode;
2025-03-31 10:36:57 +08:00
const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode)
2025-03-28 16:54:29 +08:00
kmItem.status = 2;
2025-01-14 15:34:13 +08:00
this.xmmcStr = xmmcStr;
this.xmmcCode = xmmcCode;
this.xmmcSingleCode = xmmcSingleCode
this.xmmcEndCode = xmmcCode
this.xmdm = xmdm;
this.xmxh = xmxh;
this.judgeUI.isProjectIn = true
2025-03-31 10:36:57 +08:00
Reflect.set(this.judgeUI.projectsObj, xmdm, project)
Reflect.set(this.kmItems, xmmcCode, kmItem)
2025-01-14 15:34:13 +08:00
break;
//项目结束
case 2: {
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
2025-03-28 16:54:29 +08:00
const xmmcCode = project.projectCodeCenter;
project.type = (xmjs.xmhg === 0 ? '4' : '3')
2025-01-14 15:34:13 +08:00
//计算项目是否全部结束
2025-03-31 10:36:57 +08:00
this.judgeUI.isProjectIn = (Reflect.ownKeys(judgeUI.projectsObj).filter((projectKey) => {
const fillProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, projectKey)
2025-03-28 16:54:29 +08:00
return fillProject.type == '2'
}).length) > 0;
2025-01-14 15:34:13 +08:00
if (isManualProjectIn) {
this.judgeUI.isManualProjectIn = false
}
2025-03-31 10:36:57 +08:00
const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode)
2025-03-28 16:54:29 +08:00
kmItem.status = 3;
2025-01-14 15:34:13 +08:00
//统计必考项目数量
this.xmmcStr = '无';
this.xmmcCode = '';
this.xmdm = '';
this.judgeUI.currentXmdm = undefined;
2025-03-31 10:36:57 +08:00
Reflect.set(this.judgeUI.projectsObj, xmdm, project)
Reflect.set(this.kmItems, xmmcCode, kmItem)
2025-01-14 15:34:13 +08:00
break;
}
//扣分
case 3:
2025-03-28 16:54:29 +08:00
const thisKf = this.getKfStr(`${kf.xmdm}_${kf.kfdm}`)
2025-03-31 10:36:57 +08:00
const kfObj: JudgeEventKf = {
2025-01-14 15:34:13 +08:00
//扣分项目名称
2025-03-28 16:54:29 +08:00
xmmcStr: this.getDqxmStr(kf.xmdm),
2025-01-14 15:34:13 +08:00
xmdm: kf.xmdm,
//扣分描述
desc: thisKf.desc,
//扣分分数
score: thisKf.score,
// 扣分无锡所代码
markcatalog: thisKf.markcatalog,
markserial: thisKf.markserial,
kfxh: thisKf.kfxh,
//扣分类型
type: kf.type
2025-03-28 16:54:29 +08:00
}
//扣分信息
this.kfArr.push(kfObj)
2025-01-14 15:34:13 +08:00
this.judgeUI.totalScore += thisKf.score * 1;
2025-01-20 08:50:40 +08:00
if (kf.xmdm != 20) {
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm)
2025-03-28 16:54:29 +08:00
const type = project.type;
2025-03-31 10:36:57 +08:00
project.type = (type == '3' || type == '4') ? '4' : '5'
Reflect.set(this.judgeUI.projectsObj, kf.xmdm, project)
2025-01-14 15:34:13 +08:00
}
break;
//考车状态
case 4:
this.carztStr = getCarStatus(carzt);
break;
//考试结束
case 5:
this.ksjs = ksjs;
2025-03-31 10:36:57 +08:00
await fileLog.setExamJudgeData(JSON.stringify({
method: 'examJudgeEndExam'
}))
2025-01-14 15:34:13 +08:00
break;
//项目取消
2025-01-20 08:50:40 +08:00
case 6: {
console.info(judgeTag, '项目取消');
2025-01-14 15:34:13 +08:00
const xmdm = xmqx.xmdm;
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
2025-03-28 16:54:29 +08:00
// const examSubject = this.judgeUI.examSubject
const xmmcCode = project.projectCodeCenter;
// const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode);
2025-01-14 15:34:13 +08:00
// avPlayer.playAudio([`voice/${voiceCode}.mp3`],true)
2025-03-28 16:54:29 +08:00
project.type = '1'
2025-03-31 10:36:57 +08:00
const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode)
Reflect.set(this.judgeUI.projectsObj, xmdm, project)
2025-03-28 16:54:29 +08:00
kmItem.status = 1
2025-03-31 10:36:57 +08:00
Reflect.set(this.kmItems, xmmcCode, kmItem)
2025-01-14 15:34:13 +08:00
break;
}
//语音播放和提示
case 7:
2025-03-28 16:54:29 +08:00
this.goJudgeVoice(sound)
2025-01-14 15:34:13 +08:00
break;
//模拟灯光事件
case 8:
2025-03-28 16:54:29 +08:00
this.setMndg(mndg)
2025-01-14 15:34:13 +08:00
break;
//车道和路段变化
case 9:
this.judgeUI.lane = lane
this.lane = lane;
break;
//预进项目事件
2025-01-20 08:50:40 +08:00
case 10: {
2025-03-31 10:36:57 +08:00
const param611: JudgeConfigObj = Reflect.get(judgeConfigObj, '611') || ''
2025-03-28 16:54:29 +08:00
const xmdm = precast.xmdm
const xmxh = precast.xmxh
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
2025-03-28 16:54:29 +08:00
const xmmcCode = project.projectCodeCenter
const projectCode = project.projectCode
// const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter;
// const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode;
2025-03-31 10:36:57 +08:00
const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode)
2025-03-28 16:54:29 +08:00
kmItem.status = 2;
2025-03-31 10:36:57 +08:00
Reflect.set(this.kmItems, xmmcCode, project)
2025-01-14 15:34:13 +08:00
this.xmmcStr = xmmcStr;
this.xmmcCode = xmmcCode;
this.xmdm = xmdm;
this.xmxh = xmxh;
this.xmmcSingleCode = xmmcSingleCode;
2025-03-28 16:54:29 +08:00
project.type = '2';
2025-03-31 10:36:57 +08:00
Reflect.set(this.judgeUI.projectsObj, xmdm, project)
2025-01-14 15:34:13 +08:00
}
break;
//差分事件
2025-01-20 08:50:40 +08:00
case 11: {
2025-03-27 19:01:32 +08:00
this.checkDwzt(nongps.type)
2025-01-14 15:34:13 +08:00
}
default:
break;
}
await callBack({
//项目名称 考车状态 扣分arr
2025-03-31 10:36:57 +08:00
xmmcStr: this.xmmcStr, carztStr: this.carztStr, kfArrt: this.kfArr
2025-01-14 15:13:50 +08:00
});
2025-01-14 15:34:13 +08:00
//语音播报
2025-01-20 08:50:40 +08:00
this.goVoiceAnnounce(event, xmdm, this.kfArr, xmjs, ksjs, xmxh)
2025-01-14 15:34:13 +08:00
//更新UI
if (event == 1 || event == 2 || event == 3 || event == 6) {
const copyProjectsObj = this.judgeUI.projectsObj;
judgeUI.projectsObj = deepClone(copyProjectsObj);
}
}
// 更改考试状态
2025-03-31 10:36:57 +08:00
goVoiceAnnounce =
2025-04-09 09:28:18 +08:00
async (event: number, xmdm: number, kf: JudgeEventKf[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => {
2025-03-28 16:54:29 +08:00
2025-03-31 10:36:57 +08:00
const beginProject = this.beginProject
const pointsDedute = this.pointsDedute
const endProject = this.endProject
const avPlayer = this.avPlayer
const uploadProgressPhoto = this.uploadProgressPhoto
const judgeTask = this.judgeTask
const handEndExam = this.handEndExam
const judgeUI = this.judgeUI
const checkExamIsEnd = this.checkExamIsEnd
const checkProjectIsStart = this.checkProjectIsStart
const lane = this.lane
const closeAllFiles = this.closeAllFiles
2025-03-28 16:54:29 +08:00
2025-03-31 10:36:57 +08:00
const projectsObj = judgeUI.projectsObj
const judgeConfigObj = judgeUI.judgeConfigObj
const examSubject = judgeUI.examSubject
const jl = judgeUI.jl
const isAllProjectsEnd = judgeUI.isAllProjectsEnd
2025-01-14 15:34:13 +08:00
2025-03-31 10:36:57 +08:00
const kfLen = kf.length;
//不报语音的项目列表
// const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',')
// const param611 = judgeConfigObj['611'] || '';
// const [f, s] = param611.split('/')
switch (event) {
// 项目开始
case 1:
const param512: JudgeConfigObj = (Reflect.get(judgeConfigObj, '512') || '').split(',');
const project: ProjectInfo = Reflect.get(projectsObj, xmdm)
const code = project.projectCodeCenter;
const isEnd = project.isEnd;
// const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh)
// if (!ignoreVoiceCodeArr.includes(code)) {
// if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){
// //倒出入库、桩考\进项目语音控制
// }else{
// kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true)
// }
// }
setTimeout(() => {
if (Reflect.get(param512, 7) != 0) {
clearTimeout(this.deductedPopShowTimer)
this.judgeUI.isDeductedPopShow = true
}
}, 200)
//项目已考不上传监管信息
if (!isEnd) {
judgeTask.addTask(async () => {
console.info(judgeTag, `项目开始-${xmdm}-${project.name}`)
await beginProject(xmdm)
}, {
isDelay: true
})
2025-01-14 15:34:13 +08:00
judgeTask.addTask(async () => {
2025-03-31 10:36:57 +08:00
console.info(judgeTag, `项目-${xmdm}-上传照片 start`)
await uploadProgressPhoto(xmdm)
2025-01-20 08:50:40 +08:00
}, {
isDelay: true
})
2025-03-31 10:36:57 +08:00
project.isUpload = true;
Reflect.set(this.judgeUI.projects, xmdm, project)
2025-01-14 15:34:13 +08:00
}
2025-03-31 10:36:57 +08:00
break;
2025-01-14 15:34:13 +08:00
2025-03-31 10:36:57 +08:00
// 项目结束
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) {
//项目结束了就不再生成数据
console.info(judgeTag + ' projectIsEnd =>', projectIsEnd)
if (!projectIsEnd) {
judgeTask.addTask(async () => {
console.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;
2025-01-14 15:34:13 +08:00
}
2025-03-31 10:36:57 +08:00
// 扣分
case 3:
console.info('surenjun', '扣分开始')
//扣分时实时播报语音0-否+1-是)
const currentKf = kf[kfLen -1];
2025-04-09 09:28:18 +08:00
if (JudgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '1') ||
2025-03-31 10:36:57 +08:00
(examSubject == '3' && judgeConfigObj['418'] == '1')) {
avPlayer.playAudio([`voice/${currentKf.markcatalog}.mp3`, `voice/mark_${Math.abs(currentKf.score)}.mp3`])
}
const isStart = await checkProjectIsStart(currentKf.xmdm, 2, currentKf);
if (isStart) {
await judgeTask.addTask(async () => {
console.info(judgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`)
await pointsDedute(currentKf.xmdm, currentKf)
}, {
isDelay: true
})
}
break;
2025-01-14 15:34:13 +08:00
2025-03-31 10:36:57 +08:00
// 考车状态
case 4:
break
// 考试结束
case 5:
console.info(judgeTag, '考试结束')
//关闭录像
const singlePlay = AppStorage.get<boolean>('singlePlay')
if (!singlePlay) {
await endRecordVideo(this.videoData)
}
judgeTask.addTask(async () => {
console.info(judgeTag, '考试结束 start')
AppStorage.setOrCreate('isJudge', false)
await handEndExam(ksjs)
})
// 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()
}
2025-01-14 15:34:13 +08:00
}
// 考试扣分
2025-03-31 10:36:57 +08:00
pointsDedute = async (ksxm: number, kf: JudgeEventKf) => {
2025-03-26 14:48:56 +08:00
const carInfo = AppStorage.get<CarInfoType>('carInfo');
2025-03-28 16:54:29 +08:00
const examSubject = carInfo.examSubject
const plateNo = carInfo.plateNo
const carNo = carInfo.carNo
const judgeUI = this.judgeUI
const getProjectInfo = this.getProjectInfo
const fileLog = this.fileLog
const xmmcSingleCode = this.xmmcSingleCode
const xmmcEndCode = this.xmmcEndCode
const filePath = this.filePath
const lsh = judgeUI.lsh
const idCard = judgeUI.idCard
const serialNumber = judgeUI.serialNumber
const ksdd = judgeUI.ksdd
const projectsObj = judgeUI.projectsObj
const time = GetCurrentTime();
2025-03-28 16:54:29 +08:00
const project = this.getProjectInfo(ksxm);
2025-01-14 15:34:13 +08:00
//科目三夜间行驶.模拟灯光、上车准备出现通用评判ksxm为当前进行的项目
const checkProjects = ['17', '41', '1'];
//获取正在进行的项目
2025-03-28 16:54:29 +08:00
const inProjects = Reflect.ownKeys(projectsObj).filter(projectKey => {
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(projectsObj, projectKey)
2025-03-28 16:54:29 +08:00
return project.type == '2'
});
2025-01-14 15:34:13 +08:00
let commonKsxm = '';
2025-01-20 08:50:40 +08:00
checkProjects.forEach(projectCode => {
if (inProjects.includes(projectCode)) {
2025-01-14 15:34:13 +08:00
commonKsxm = projectCode
}
})
2025-03-31 10:36:57 +08:00
const ksxmD: string = project == undefined
2025-03-28 16:54:29 +08:00
? (commonKsxm
? (project.projectCodeCenter)
: (examSubject == '3' ? '30000' : (xmmcEndCode == undefined ? '10000' : xmmcEndCode)))
: project.projectCodeCenter
2025-03-31 10:36:57 +08:00
const drvexam: DrvexamType = {
2025-03-28 16:54:29 +08:00
lsh,
kskm: examSubject,
2025-03-31 10:36:57 +08:00
ksxm: ksxmD,
2025-03-28 16:54:29 +08:00
kfxm: kf.markcatalog,
kfxmmx: `${ksxm},${kf.markserial}`,
sfzmhm: idCard,
kchp: encodeURI(carInfo.plateNo),
//扣分方式
kffs: kf.type == 0 ? 1 : 2,
ksdd: encodeURI(ksdd),
kfsj: time
2025-01-14 15:34:13 +08:00
}
2025-03-31 10:36:57 +08:00
const data: RegulatoryInterfaceParams = {
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C53',
drvexam
}
2025-01-20 08:50:40 +08:00
console.info(judgeTag + 'ksxm=>', data.drvexam.ksxm)
2025-01-14 15:34:13 +08:00
2025-03-28 16:54:29 +08:00
const temp = await this.sendWriteObjectOut(data, filePath);
if (temp.code == 2300007) {
2025-01-14 15:34:13 +08:00
this.isJudgeDisConnect = true
}
console.info(judgeTag, '项目扣分 end')
2025-03-31 10:36:57 +08:00
promptWxCode('17C53', temp.code)
2025-01-14 15:34:13 +08:00
}
// 评判语音提示
2025-03-28 16:54:29 +08:00
goJudgeVoice = async (sound: JudgeSound) => {
const avPlayer = this.avPlayer
const fileLog = this.fileLog
console.info('surenjun code=>', JSON.stringify(sound.code))
2025-01-14 15:34:13 +08:00
//判断是不是模拟灯光语音
2025-03-28 16:54:29 +08:00
if (sound.type == 1) {
avPlayer.playAudio([`voice/${sound.code[0]}.mp3`], false, () => {
2025-03-31 10:36:57 +08:00
examJudgeSoundEnd({
2025-03-28 16:54:29 +08:00
xmdm: sound.xmdm, code: sound.code[0], type: sound.type
2025-01-14 15:34:13 +08:00
})
2025-03-28 16:54:29 +08:00
fileLog.setExamJudgeData(JSON.stringify({
2025-01-14 15:34:13 +08:00
method: 'examJudgeSoundEnd',
2025-03-28 16:54:29 +08:00
itemno: sound.xmdm,
code: sound.code[0],
2025-03-31 10:36:57 +08:00
type: sound.type,
2025-03-28 16:54:29 +08:00
}))
2025-01-14 15:34:13 +08:00
})
2025-01-20 08:50:40 +08:00
} else {
2025-03-28 16:54:29 +08:00
avPlayer.playAudio([`voice/${sound.code[0]}.mp3`])
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
}
2025-01-14 15:34:13 +08:00
// 处理考试结束
public handEndExam = async (ksjs: KSJS) => {
this.judgeUI.loadingPopupVisible = true;
this.judgeUI.endPopupVisible = false;
this.judgeUI.isDeductedPopShow = false;
2025-03-28 16:54:29 +08:00
const judgeUI = this.judgeUI
const endExam = this.endExam
const handleSEP = this.handleSEP
const kfArr = this.kfArr
const avPlayer = this.avPlayer
const judgeTask = this.judgeTask
const isManual = this.isManual
const closeAllFiles = this.closeAllFiles
const judgeConfigObj = judgeUI.judgeConfigObj
const examSubject = judgeUI.examSubject
const isAllProjectsEnd = judgeUI.isAllProjectsEnd
const totalScore = judgeUI.totalScore
const passingScore = judgeUI.passingScore
2025-01-14 15:34:13 +08:00
//计算考试分数
// this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0;
2025-03-26 14:48:56 +08:00
const singlePlay = AppStorage.get<boolean>('singlePlay')
2025-03-31 10:36:57 +08:00
const param302: string = Reflect.get(judgeConfigObj, '302')
2025-01-14 15:34:13 +08:00
// globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
//自动退出待验证并且不合格
2025-03-28 16:54:29 +08:00
if (!isManual && examSubject == '3' && (param302 == '1' || (singlePlay && param302 == '2')) &&
2025-02-11 09:18:16 +08:00
totalScore < passingScore) {
2025-01-14 15:34:13 +08:00
avPlayer.playAudio([`voice/考试结束.mp3`])
}
//联网模式下手动结束的直接退出
if (!singlePlay && isManual && !isAllProjectsEnd) {
avPlayer.playAudio(['voice/empty.mp3'], true, () => {
this.isUdpEnd = true;
closeAllFiles()
router.back();
})
return
}
2025-03-28 16:54:29 +08:00
if (examSubject == '3') {
2025-01-14 15:34:13 +08:00
if (totalScore < passingScore) {
//考试不合格;考试模式,自动退出;
2025-03-31 10:36:57 +08:00
if (param302 == '4' || param302 == '5' || param302 == '7' || param302 == '8') {
}
2025-01-14 15:34:13 +08:00
} else {
//考试合格
}
}
await handleSEP(306);
2025-02-13 15:30:48 +08:00
avPlayer.playAudio(['voice/exam_waiting.mp3'], AppStorage.get('singlePlay'), async () => {
2025-01-14 15:34:13 +08:00
try {
if (!singlePlay) {
2025-03-28 16:54:29 +08:00
// TODO const bytes = await this.getMessageHeartbeat(true);
// TODO globalThis.judgeUdp.send(bytes)
2025-01-14 15:34:13 +08:00
}
} catch (e) {
2025-01-20 08:50:40 +08:00
console.info(judgeTag, JSON.stringify(e))
2025-01-14 15:34:13 +08:00
}
await endExam()
2025-01-14 15:34:13 +08:00
});
}
// 考试结束
public endExam = async (isManual?: Boolean) => {
2025-03-26 14:48:56 +08:00
const carInfo = AppStorage.get<CarInfoType>('carInfo');
const singlePlay = AppStorage.get<boolean>('singlePlay')
2025-03-28 16:54:29 +08:00
const examSubject = carInfo.examSubject
const plateNo = carInfo.plateNo
const judgeUI = this.judgeUI
const ksjs = this.ksjs
const getPhoto = this.getPhoto
const avPlayer = this.avPlayer
const kfArr = this.kfArr
const filePath = this.filePath
const closeAllFiles = this.closeAllFiles
const lsh = judgeUI.lsh;
const idCard = judgeUI.idCard;
const serialNumber = judgeUI.serialNumber;
const kssycs = judgeUI.kssycs;
const totalScore = judgeUI.totalScore;
const judgeConfigObj = judgeUI.judgeConfigObj;
const isAllProjectsEnd = judgeUI.isAllProjectsEnd;
const passingScore = judgeUI.passingScore;
2025-01-14 15:34:13 +08:00
//TODO 断网考试结束补传
// await uploadDisConnectData();
const time = GetCurrentTime();
2025-01-14 15:34:13 +08:00
const photoBase64 = await getPhoto();
2025-03-28 16:54:29 +08:00
const d1 = ksjs.d1;
const d2 = ksjs.d2;
const d3 = ksjs.d3;
const d4 = ksjs.d4;
const d5 = ksjs.d5;
2025-03-31 10:36:57 +08:00
const drvexam: DrvexamType = {
2025-03-28 16:54:29 +08:00
lsh,
kchp: encodeURI(plateNo),
kskm: examSubject,
sfzmhm: idCard,
zp: photoBase64,
jssj: time,
kscj: (totalScore * 1) > 0 ? totalScore : 0,
kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100),
// 1,22;2,560;3,128;4,0;5,0;
dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'),
2025-01-14 15:34:13 +08:00
}
2025-03-28 16:54:29 +08:00
2025-03-31 10:36:57 +08:00
const data: RegulatoryInterfaceParams = {
xtlb: '17',
jkxlh: serialNumber,
jkid: '17C56',
drvexam
}
2025-01-20 08:50:40 +08:00
let backTimeOut = setTimeout(() => {
router.back()
}, 90 * 1000)
2025-03-28 16:54:29 +08:00
const temp = await this.sendWriteObjectOut(data, filePath);
2025-03-31 10:36:57 +08:00
promptWxCode('17C56', temp.code)
2025-01-14 15:34:13 +08:00
2025-03-28 16:54:29 +08:00
if (temp.code != 1) {
2025-01-14 15:34:13 +08:00
avPlayer.playAudio(['voice/监管失败.mp3'])
2025-03-28 16:54:29 +08:00
this.judgeUI.errorMsg = decodeURIComponent(temp.message)
2025-01-14 15:34:13 +08:00
2025-03-28 16:54:29 +08:00
if (temp.code == 2300028 || temp.code == 2300007) {
2025-01-14 15:34:13 +08:00
this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!'
}
this.isUdpEnd = true;
closeAllFiles()
this.judgeUI.loadingPopupVisible = false;
return
}
console.info(judgeTag, '考试结束 end')
2025-03-31 10:36:57 +08:00
const param302: string = Reflect.get(judgeConfigObj, '302')
2025-01-14 15:34:13 +08:00
judgeUI.loadingPopupVisible = true;
2025-03-28 16:54:29 +08:00
let currentKssycs = '0';
2025-01-14 15:34:13 +08:00
let voiceURL = ''
2025-03-28 16:54:29 +08:00
if (examSubject == '2') {
2025-01-14 15:34:13 +08:00
if (isAllProjectsEnd) {
2025-02-11 09:18:16 +08:00
voiceURL =
2025-03-28 16:54:29 +08:00
(totalScore < passingScore ? `voice/unqualified_${kssycs == '1' ? 'one' : 'two'}.wav` : 'voice/qualified.mp3')
2025-01-20 08:50:40 +08:00
} else {
2025-03-28 16:54:29 +08:00
voiceURL = `voice/unqualified_${kssycs == '1' ? 'one' : 'two'}.wav`
currentKssycs = kssycs == '1' ? '0' : '1'
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
switch (voiceURL) {
2025-01-14 15:34:13 +08:00
case 'voice/unqualified_one.wav':
2025-03-28 16:54:29 +08:00
currentKssycs = '0';
2025-01-14 15:34:13 +08:00
break;
case 'voice/unqualified_two.wav':
2025-03-28 16:54:29 +08:00
currentKssycs = '1';
2025-01-14 15:34:13 +08:00
break;
case 'voice/qualified.mp3':
2025-03-28 16:54:29 +08:00
currentKssycs = '0';
2025-01-14 15:34:13 +08:00
break;
}
}
2025-03-28 16:54:29 +08:00
if (examSubject == '3') {
2025-01-14 15:34:13 +08:00
if (isAllProjectsEnd) {
if (totalScore < passingScore) {
2025-03-28 16:54:29 +08:00
voiceURL = `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3`
currentKssycs = kssycs == '1' ? '0' : '1'
2025-01-14 15:34:13 +08:00
} else {
voiceURL = 'voice/exam_pass.mp3'
2025-03-28 16:54:29 +08:00
currentKssycs = '0'
2024-07-31 13:47:40 +08:00
}
2025-01-14 15:34:13 +08:00
} else {
2025-03-28 16:54:29 +08:00
voiceURL = `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3`
currentKssycs = kssycs == '1' ? '0' : '1'
2024-07-11 10:22:31 +08:00
}
2025-01-20 08:50:40 +08:00
switch (voiceURL) {
2025-01-14 15:34:13 +08:00
case 'voice/exam_no_pass_finish.mp3':
2025-03-28 16:54:29 +08:00
currentKssycs = '0';
2025-01-14 15:34:13 +08:00
break;
2024-08-19 10:11:22 +08:00
2025-01-14 15:34:13 +08:00
case 'voice/exam_no_pass.mp3':
2025-03-28 16:54:29 +08:00
currentKssycs = '1';
2025-01-14 15:34:13 +08:00
break;
case 'voice/exam_pass.mp3':
2025-03-28 16:54:29 +08:00
currentKssycs = '0';
2025-01-14 15:34:13 +08:00
break;
}
}
2025-03-28 16:54:29 +08:00
const USER = await GetSyncData<User>('USER');
USER[0].kssycs = currentKssycs
await SqlInsertTable('USER', USER)
2025-01-14 15:34:13 +08:00
console.info(judgeTag, `考试成绩:${totalScore}`)
2025-01-20 08:50:40 +08:00
if (!singlePlay) {
// await uploadProgressData();
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
clearTimeout(backTimeOut)
2025-01-14 15:34:13 +08:00
//语音播放扣分项
let score = 0;
//结束考试时候是否播报一遍所有扣分
2025-03-31 10:36:57 +08:00
const param634: string = Reflect.get(judgeConfigObj, '634')
2025-03-28 16:54:29 +08:00
if (kfArr.length && ((examSubject == '2' && param634 == '1') || examSubject == '3')) {
2025-01-14 15:34:13 +08:00
avPlayer.playAudio([`voice/kfdesc.mp3`], false, () => {
try {
kfArr.forEach((kf, index) => {
score += Math.abs(Number(kf.score));
//TODO 考试分数待替换
2025-03-28 16:54:29 +08:00
if (score <= (examSubject == '3' ? 10 : 20)) {
2025-01-14 15:34:13 +08:00
if (kfArr.length - 1 === index) {
avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => {
this.isUdpEnd = true;
closeAllFiles()
router.back();
})
throw new Error('End Loop')
}
avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`])
} else {
avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => {
this.isUdpEnd = true;
closeAllFiles()
router.back();
})
throw new Error('End Loop')
}
})
} catch (e) {
2025-01-20 08:50:40 +08:00
console.info(judgeTag, JSON.stringify(e))
2024-07-05 09:08:17 +08:00
}
2025-01-14 15:34:13 +08:00
})
} else {
avPlayer.playAudio([voiceURL], true, () => {
setTimeout(() => {
this.isUdpEnd = true
closeAllFiles()
router.back();
2025-03-28 16:54:29 +08:00
}, param302 == '8' ? 3000 : 0)
2025-01-14 15:34:13 +08:00
})
}
2025-01-20 08:50:40 +08:00
2025-01-14 15:34:13 +08:00
}
// 当前项目转换
2025-03-31 10:36:57 +08:00
getDqxmStr: GetDqxmStr = (xmdm) => {
const project: ProjectInfo = Reflect.get(this.judgeUI.projectsObj, xmdm)
2025-03-28 16:54:29 +08:00
return project?.abbreviation || '通用评判'
2025-01-14 15:34:13 +08:00
}
// 扣分项目转换
2025-03-31 10:36:57 +08:00
getKfStr: GetKfStr = (code) => {
2025-01-14 15:34:13 +08:00
const markRuleListObj = this.judgeUI.markRuleListObj;
2025-03-31 10:36:57 +08:00
const thisMark: MarkRule = Reflect.get(markRuleListObj, code)
2025-01-14 15:34:13 +08:00
return {
desc: thisMark.markshow,
score: thisMark.markreal,
markcatalog: thisMark.markcatalog,
markserial: thisMark.markserial,
kfxh: thisMark.kfxh
}
}
// 消息心跳发送
2025-03-28 16:54:29 +08:00
// getMessageHeartbeat = async (isEnd?: Boolean) => {
// const carInfo = AppStorage.get<CarInfoType>('carInfo');
// const { examSubject, plateNo, ksyh } = carInfo;
// const {
// judgeUI,
// isExam,
// serialIndex,
// tempData,
// xmmcCode,
// xmxh,
// xmmcSingleCode,
// xmdm,
// performInfo,
// kfArr,
// getTranslateProject,
// getSbxh,
// fileLog,
// } = this;
// const singlePlay = AppStorage.get<boolean>('singlePlay')
// const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI;
// const {
// fourInOneScreen:{
// gpsDigit
// }
// } = judgeConfig
// const examType = examSubject == 2 ? 2 : 3
// const { sensor, gps } = tempData;
// if (tempData.sensor === undefined) {
// return
// }
// const { zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, ygq, cs, fdjzs, dw } = sensor
// const { jd, wd, hxj, fyj, hbg, sd } = gps;
//
// //过滤错误数据
// if (jd == 0) {
// return
// }
// const translateProject = getTranslateProject();
// const sbxh = getSbxh(xmdm, xmxh)
// const { carzt, dcjl, qjjl, dxjl, bxjl } = performInfo || {};
// const asclshArr = StringToASCII(
// fillZero((singlePlay ? (examSubject == 2 ? '0000000000000' : '1111111111111') : lsh) || 0, 13)
// );
// //13不足要补0
// const ascksyhArr = StringToASCII(fillZero(ksyh || 0, 13))
// const ascsbxhArr = StringToASCII(sbxh)
// const translateSignals = getTranslateSignals(
// [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw))
// .concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0])
// )
// const translateJd = convertGpsCoord2(wd).toFixed(gpsDigit) * Math.pow(10, gpsDigit);
// const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit)
// const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0])
//
// let tempSd = ((judgeConfigObj['350'] == 0 ? sd : cs) * 1.852).toFixed(0) * 1
// if (tempSd < 1) {
// tempSd = 0
// }
//
// const arr = [
// //考生号
// asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
// //考试员号
// ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
// //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间
// string2Bytes(`${examType}${AppStorage.get('startHourTime') || startHourTime}`, 4 * 8),
// // TODO 消息序号从1开始0结束
// string2Bytes(isEnd ? 0 : serialIndex, 2 * 8),
// /*左向灯 右向灯 双跳灯 远光灯 近光灯 视宽灯 点火1 点火2 离合器 脚刹 手刹 副刹 喇叭 门开关 安全带 档位 车辆状态 雨刮器 雾灯 0*/
// translateSignals,
// //速度 发动机转速 GPS纬度 GPS经度 主天线位置
// string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8),
// string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8),
// //GPS东向距离
// string2Bytes(dxjl < 0 ? (dxjl + 4294967296) : dxjl, 4 * 8),
// //GPS北向距离
// string2Bytes(bxjl < 0 ? (bxjl + 4294967296) : bxjl, 4 * 8),
// //航向角 俯仰角 高程(海拔)
// string2Bytes((hxj) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8),
// //项目状态 parseInt('01010010',2) 二进制转成10进制
// translateProjects,
// //当前项目编号
// string2Bytes(xmmcSingleCode ? (xmmcSingleCode * 1 + 1) : 0, 8),
// //场地设备编号
// ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]),
// //本次考试行驶距离
// string2Bytes(Math.floor((dcjl + qjjl) / 100), 2 * 8),
// //扣分
// string2Bytes(100 - Math.abs(totalScore), 2 * 8),
// //扣分项数量
// string2Bytes(kfArr.length, 8),
// //n个扣分序号
// kfArr.map(kf => string2Bytes(kf.kfxh, 8)[0]),
// //TODO 牵引车第二gps精度、纬度
// string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8),
// //TODO 牵引车第二航向角
// string2Bytes(0, 2 * 8),
// //TODO 摩托压线 Byte[20],
// string2Bytes(0, 20 * 8),
// //考试用时
// string2Bytes(examTime, 4 * 8),
// //TODO 项目用时
// string2Bytes(fillZero(0, 2), 2 * 8),
// //TODO 设备信号状态
// string2Bytes(0, 4 * 8),
// ]
//
// let tempArr = [];
// arr.forEach(itemArr => {
// tempArr = tempArr.concat(itemArr)
// })
// this.serialIndex += 1;
// fileLog.setFourAndOneLogData(`${lsh},${ksyh},${examType}${AppStorage.get('startHourTime') || startHourTime},`);
// fileLog.setFourAndOneLogDataBytes(tempArr.toString());
// return Array2Byte(tempArr)
// }
2025-01-14 15:34:13 +08:00
//获取场地序号
2025-03-31 10:36:57 +08:00
getSbxh: GetgSbbm = (ksxm, xmxh) => {
2025-03-28 16:54:29 +08:00
const judgeUI = this.judgeUI;
const projectsObj = judgeUI.projectsObj;
const cdsbInfoObj = judgeUI.cdsbInfoObj;
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(projectsObj, ksxm);
2025-03-28 16:54:29 +08:00
if (judgeUI.examSubject == '3') {
2025-01-14 15:34:13 +08:00
return '0000000000'
}
if (project === undefined) {
return '0000000000'
}
const projectKey = `${ksxm}_${xmxh}`;
2025-03-31 10:36:57 +08:00
const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {}
const sbxh: string = currentCdsb.sbbh || '0000000000'
2025-01-14 15:34:13 +08:00
return sbxh
}
2025-03-31 10:36:57 +08:00
getSbbm: GetgSbbm = (ksxm, xmxh) => {
2025-03-27 19:01:32 +08:00
const judgeUI = this.judgeUI;
const cdsbInfoObj = judgeUI.cdsbInfoObj;
const projectsObj = judgeUI.projectsObj;
2025-03-31 10:36:57 +08:00
const project: ProjectInfo = Reflect.get(projectsObj, ksxm);
2025-01-20 08:50:40 +08:00
//科目三不需要
2025-03-28 16:54:29 +08:00
if (judgeUI.examSubject == '3') {
2025-01-20 08:50:40 +08:00
return undefined
}
if (project === undefined) {
return '00000000'
}
const projectKey = `${ksxm}_${xmxh}`;
2025-03-31 10:36:57 +08:00
const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {}
const sbxh: string = currentCdsb.sbbm || '00000000'
2025-03-28 16:54:29 +08:00
return sbxh
2025-01-20 08:50:40 +08:00
}
// 中心所有项目转换
getTranslateProject = () => {
2025-03-28 16:54:29 +08:00
const examSubject = this.judgeUI.examSubject;
2025-03-31 10:36:57 +08:00
const tempItems: TKmItem[] = (examSubject == '2' ? testKm2Items : testKm3Items).map(item => {
const kmItem: KmItem = Reflect.get(this.kmItems, item.code)
2025-03-28 16:54:29 +08:00
const status = getCenterProjectStatus(kmItem.status)
2025-03-31 10:36:57 +08:00
const temp: TKmItem = {
code: item.code, status
}
2025-03-28 16:54:29 +08:00
return temp
2025-01-20 08:50:40 +08:00
})
2025-03-31 10:36:57 +08:00
const arr: string[] = [];
2025-01-20 08:50:40 +08:00
for (let i = 0; i <= 4; i++) {
const temp = tempItems.slice(i * 4, (i + 1) * 4);
let tempArr = temp.map(item => item.status)
if (i === 4) {
2025-03-28 16:54:29 +08:00
tempArr = examSubject == '2'
2025-01-20 08:50:40 +08:00
//bit36-bit39保留
? tempArr.concat(['00', '00'])
//bit30-bit39保留
: tempArr.concat(['00', '00', '00'])
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
// if (i === 3 && examSubject == 3) {
// tempArr = tempArr.concat(['00'])
// }
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
arr.push(tempArr.join(''));
}
return arr
}
// 获取考试项目详情
2025-03-31 10:36:57 +08:00
getProjectInfo = (projectCode: number) => {
const project: ProjectInfo = Reflect.get(this.judgeUI.projectsObj, projectCode)
2025-03-28 16:54:29 +08:00
return project
2025-01-20 08:50:40 +08:00
}
// 获取模型数据
2025-03-31 10:36:57 +08:00
getModelData = (modelName: string) => {
2025-03-28 16:54:29 +08:00
const modelData = this.fileModel.getModelContent(this.modelPath, modelName);
2025-01-20 08:50:40 +08:00
return modelData
2025-01-14 15:34:13 +08:00
}
// 统计必考项目、所有项目、已考数量
setCountItems = async () => {
2025-03-28 16:54:29 +08:00
const projectsObj = this.judgeUI.projectsObj;
2025-01-14 15:34:13 +08:00
//必考项目数量 必考项目已考数量
let projectNum = 0, endProjectsNum = 0;
// 所有考试项目数量 项目已考项目数量
let allProjectNum = 0, allEndProjectsNum = 0;
Reflect.ownKeys(projectsObj).forEach(projectKey => {
2025-03-31 10:36:57 +08:00
const projectObj: ProjectInfo = Reflect.get(projectsObj, projectKey)
2025-03-28 16:54:29 +08:00
const type = projectObj.type
const isRequired = projectObj.isRequired
2025-01-14 15:34:13 +08:00
allProjectNum += 1;
2025-03-28 16:54:29 +08:00
if (type == '3' || type == '4') {
2025-01-14 15:34:13 +08:00
allEndProjectsNum += 1;
}
if (isRequired) {
projectNum += 1;
2025-03-28 16:54:29 +08:00
if (type == '3' || type == '4') {
2025-01-14 15:34:13 +08:00
endProjectsNum += 1;
2024-07-11 10:22:31 +08:00
}
2024-07-31 13:47:40 +08:00
}
2025-01-14 15:34:13 +08:00
})
2025-03-28 16:54:29 +08:00
2025-01-20 08:50:40 +08:00
console.info(judgeTag, '项目状态projectsObj:' + JSON.stringify(projectsObj));
console.info(judgeTag, '所有考试项目数量:' + allProjectNum)
console.info(judgeTag, '必考项目数量:' + projectNum)
console.info(judgeTag, '必考项目已考数量:' + endProjectsNum)
2025-01-14 15:34:13 +08:00
//必考项目除靠边停车是否全部完成
this.judgeUI.isRequiredProjectsEnd = (projectNum - endProjectsNum === 0)
this.judgeUI.isAllProjectsEnd = (allProjectNum - allEndProjectsNum === 0)
}
// 检测差分状态
2025-03-31 10:36:57 +08:00
checkDwzt = async (type: number) => {
2025-03-28 16:54:29 +08:00
const avPlayer = this.avPlayer;
2025-01-20 08:50:40 +08:00
switch (type) {
2025-01-14 15:34:13 +08:00
case 0:
this.judgeUI.isDwztRight = true;
break;
case 1:
this.judgeUI.dwztErrorVisible = true;
2025-01-20 08:50:40 +08:00
avPlayer.playAudio([`voice/差分状态异常.mp3`], true)
setTimeout(() => {
2025-01-14 15:34:13 +08:00
router.back()
2025-01-20 08:50:40 +08:00
}, 3000)
2025-01-14 15:34:13 +08:00
break;
case 2:
2025-01-20 08:50:40 +08:00
avPlayer.playAudio([`voice/差分状态异常.mp3`], true);
2025-01-14 15:34:13 +08:00
break;
case 3:
this.judgeUI.dwztErrorVisible = true;
2025-01-20 08:50:40 +08:00
avPlayer.playAudio([`voice/差分状态异常.mp3`], true);
2025-01-14 15:34:13 +08:00
break;
case 4:
this.judgeUI.isDwztRight = false;
2025-02-11 09:18:16 +08:00
//差分异常上报
2025-01-14 15:34:13 +08:00
break;
2024-08-23 15:59:56 +08:00
}
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
closeAllFiles = () => {
setTimeout(() => {
2025-01-14 15:34:13 +08:00
this.fileLog.closeAllFiles()
2025-01-20 08:50:40 +08:00
}, 1000)
2025-01-14 15:34:13 +08:00
}
2025-01-20 08:50:40 +08:00
//开始评判
private async judging(callBack: Function) {
2025-03-31 10:36:57 +08:00
const judgeUI = this.judgeUI;
2025-03-28 16:54:29 +08:00
const name = judgeUI.name
const lsh = judgeUI.lsh
const idCard = judgeUI.idCard
const kssycs = judgeUI.kssycs
const manualMarkRules = judgeUI.manualMarkRules
2025-01-20 08:50:40 +08:00
const fileLog = new FileLog(judgeUI.context);
const filePath = await fileLog.initFileLogo({
name, lsh, idCard
});
this.fileLog = fileLog;
this.filePath = filePath;
2025-01-14 15:34:13 +08:00
2025-03-28 16:54:29 +08:00
const getJudgeBeginData = this.getJudgeBeginData;
const handleUdp = this.handleUdp;
const handDistance = this.getJudgeBeginData;
const handleTrajectoryUdp = this.handleTrajectoryUdp;
const isTrajectoryOpen = this.isTrajectoryOpen;
const trajectoryPath = this.trajectoryPath;
const avPlayer = this.avPlayer;
const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool');
2025-03-31 10:36:57 +08:00
let strArr: string[] = [];
2025-01-20 08:50:40 +08:00
if (isTrajectoryOpen) {
const folderPath = await this.fileUtil.initFolder(trajectoryPath);
2025-03-31 10:36:57 +08:00
const str: string = await this.fileUtil.readFile(folderPath)
2025-01-20 08:50:40 +08:00
strArr = str.split('\n')
}
//日志回调
console.info(judgeTag, '1.进入评判入口')
2025-03-31 10:36:57 +08:00
await examJudgeSetLogCallback(3, async (level: number, info: string, len: number) => {
2025-01-20 08:50:40 +08:00
console.log('评判日志:' + info)
await fileLog.setExamJudgeLogData(info);
})
2025-01-14 15:34:13 +08:00
2025-01-20 08:50:40 +08:00
console.info(judgeTag, '2.注册日志回调完成')
2025-03-31 10:36:57 +08:00
let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData();
2025-03-28 16:54:29 +08:00
await fileLog.setExamJudgeData(JSON.stringify(initInfo))
2025-01-20 08:50:40 +08:00
//相关评判初始化只做一次
if (!isJudgeInitBool) {
const tempJudge = await examJudgeInit(initInfo);
AppStorage.setOrCreate('isJudgeInitBool', true)
2025-01-20 08:50:40 +08:00
console.info(judgeTag, '4.评判初始化完成')
}
AppStorage.setOrCreate('isJudge', true)
2025-01-20 08:50:40 +08:00
// 2.评判过程回调
2025-03-31 10:36:57 +08:00
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
2025-01-20 08:50:40 +08:00
await fileLog.setExamJudgeCallbackData(strData)
console.info('评判回调数据', strData)
this.handleRealExam(strData, callBack)
})
2025-03-31 10:36:57 +08:00
await examJudgeSetPerformCallback(async (info: string) => {
2025-01-20 08:50:40 +08:00
console.info('评判实时数据', info)
2025-03-31 10:36:57 +08:00
const performInfo: JudgePerformInfo = JSON.parse(info)
2025-01-20 08:50:40 +08:00
this.performInfo = performInfo
const jl = Math.floor((performInfo.qjjl + performInfo.dcjl) / 100);
2025-03-28 16:54:29 +08:00
if (jl > Number(this.judgeUI.examMileage)) {
2025-01-20 08:50:40 +08:00
this.checkExamIsEnd()
}
this.judgeUI.jl = jl
//TODO 待优化 跨组件传值不生效
2025-03-28 16:54:29 +08:00
// globalThis.laneData = performInfo.lane;
2025-01-20 08:50:40 +08:00
})
2025-03-31 10:36:57 +08:00
let beginExamInfo: JudgeBeginObj = undefined
2025-01-20 08:50:40 +08:00
// 3.开始考试
2025-03-31 10:36:57 +08:00
if (isTrajectoryOpen) {
beginExamInfo = JSON.parse(strArr[1])
2025-03-28 16:54:29 +08:00
beginExamInfo.replay = 1
2025-03-31 10:36:57 +08:00
} else {
2025-03-28 16:54:29 +08:00
beginExamInfo = await getJudgeBeginData()
}
await fileLog.setExamJudgeData(JSON.stringify(beginExamInfo))
2025-01-20 08:50:40 +08:00
await examJudgeBeginExam(beginExamInfo);
console.info(judgeTag, '6.开始考试注册完成')
2025-03-28 16:54:29 +08:00
avPlayer.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
2025-01-20 08:50:40 +08:00
2025-03-28 16:54:29 +08:00
if (!judgeUI.singlePlay) {
this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, this.context)
2025-01-20 08:50:40 +08:00
}
// if(examSubject == 3){
// //不做模拟灯光,需要做上车准备 =>(请上车准备)
// if(projectsObj[41]?.type == 3 && projectsObj[1]?.type != 3){
// avPlayer.playAudio(['voice/上车准备.mp3'])
// }
// //不做模拟灯光,不做上车准备 =>(请起步,完成考试)
// if(projectsObj[41]?.type == 3 && projectsObj[1]?.type == 3){
// avPlayer.playAudio(['voice/402001.mp3'])
// }
// }
this.judgeUI.draw = true
// 处理轨迹plc信息
if (isTrajectoryOpen) {
handleTrajectoryUdp(strArr);
return
}
// 处理实时udp里的plc信号
// globalThis.udpClient.closeMessage_1();
2025-03-28 16:54:29 +08:00
//TODO UDP修改
// globalThis.udpClient.onMessage_1(async (msg) => {
// console.info('socketTag[PLC.UdpClient]', '收到udp回调数据')
// handleUdp(msg)
// const udpIndex = globalThis.udpIndex;
// if (udpIndex % 5 === 0) {
// handDistance();
// }
// });
2025-01-20 08:50:40 +08:00
// this.checkExamIsEnd()
2025-03-28 16:54:29 +08:00
//TODO 监听远程结束考试
// globalThis.udpEvent.onEndExam(async () => {
// this.checkExamIsEnd(true);
// })
2025-01-20 08:50:40 +08:00
console.info(judgeTag, JSON.stringify(manualMarkRules))
2025-03-28 16:54:29 +08:00
//TODO 监听远程扣分
// globalThis.udpEvent.onKfExam(async (content:JudgeUdpKf) => {
// console.info('评判收到远程扣分项目内容' + JSON.stringify(content))
// const kfxh = content.data.kfxh;
// const directives = content.data.directives;
// console.info(judgeTag, '评判收到远程扣分项目内容,扣分序号:' + `kfxh=>${kfxh}; directives=>${directives}`)
// //根据扣分序号找扣分代码
// const currentKf:MarkRule = manualMarkRules.filter(mark => mark.kfxh == kfxh)[0];
// console.info(judgeTag, '扣分项目:' + JSON.stringify(currentKf))
// this.setJudgeMark(String(currentKf.itemno), currentKf.markserial, 2);
// //TODO
// //globalThis.judgeUdp.confirmKf(directives, 1)
// })
2025-01-20 08:50:40 +08:00
this.checkExamIsEnd();
}
2025-01-14 15:34:13 +08:00
}