fix: 修改评判结构
This commit is contained in:
parent
db5ade8ba0
commit
575d38f2fa
@ -39,6 +39,7 @@ struct Index {
|
||||
@State num: number = 0;
|
||||
@State isPlay: boolean = false;
|
||||
@State initWork: boolean = false
|
||||
@State status: string = "开始"
|
||||
// 请求网络表等待弹窗
|
||||
customDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: CarLoadingComponent(),
|
||||
@ -216,6 +217,7 @@ struct Index {
|
||||
HeaderComponent({
|
||||
shortLogo: false
|
||||
})
|
||||
|
||||
CardComponent({
|
||||
isSingle: this.singlePlay,
|
||||
singleClick: () => {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import {
|
||||
JudgeConfigObjKmItems,
|
||||
JudgeKSJS,
|
||||
JudgePerformInfo,
|
||||
JudgeUI,
|
||||
LANE,
|
||||
MarkRule,
|
||||
PLCType,
|
||||
ProcessDataEnumType,
|
||||
@ -41,6 +43,9 @@ export default class JudgeBusiness {
|
||||
//所有的科目考试项目(大车&小车)
|
||||
public kmItems: JudgeConfigObjKmItems
|
||||
public xmmcStr: string = ""
|
||||
public lane: LANE = {
|
||||
road: '', num: 0, count: 0
|
||||
}
|
||||
public xmmcCode: string = ""
|
||||
public xmmcSingleCode: string = ""
|
||||
public xmmcEndCode?: string
|
||||
@ -48,12 +53,13 @@ export default class JudgeBusiness {
|
||||
public xmxh: string = ""
|
||||
public kfArr?: MarkRule[]
|
||||
public carztStr: string
|
||||
public ksjs?: JudgeKSJS
|
||||
public mndgStr: string | undefined
|
||||
private judgeUI: JudgeUI
|
||||
private tempData?: PLCType
|
||||
private plcData?: PLCType
|
||||
// 是否发送udp
|
||||
private isUdpEnd: boolean = false
|
||||
private mndgStr: string | undefined
|
||||
|
||||
constructor(judgeUI: JudgeUI) {
|
||||
this.judgeUI = judgeUI
|
||||
|
||||
@ -3,7 +3,7 @@ import { JudgeCallBackData, JudgeUI, KmItem, MarkRule, ProcessDataEnumType, Proj
|
||||
import { dConsole } from '../../utils/LogWorker';
|
||||
import JudgeBusiness from './JudgeBusiness';
|
||||
import { examJudgeArtificialItem } from './JudgeSDKUtils';
|
||||
import { CurrentProjectConversion, DeductionProjectConversion } from './utils';
|
||||
import { CurrentProjectConversion, DeductionProjectConversion, GetCarStatus } from './utils';
|
||||
|
||||
export const JudgingFn = async (strData: string, callBack: Function, judgeUI: JudgeUI, that: JudgeBusiness) => {
|
||||
let examData: JudgeCallBackData = JSON.parse(strData);
|
||||
@ -26,13 +26,9 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju
|
||||
const isManualProjectIn = artSubject3ProjectsCodesArr.includes(xmdm);
|
||||
const examSubject = judgeUI.examSubject
|
||||
const judgeConfigObj = judgeUI.judgeConfigObj
|
||||
let project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
|
||||
const xmmcCode = project.projectCodeCenter || "";
|
||||
const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode)
|
||||
|
||||
switch (event) {
|
||||
// 项目开始
|
||||
case 1:
|
||||
case 1: {
|
||||
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
|
||||
project.type = '2';
|
||||
if (isManualProjectIn) {
|
||||
//手动项目是否在进行中
|
||||
@ -43,7 +39,9 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju
|
||||
}
|
||||
judgeUI.currentXmdm = xmdm;
|
||||
const xmmcStr = project.name || "";
|
||||
const xmmcCode = project.projectCodeCenter || "";
|
||||
const xmmcSingleCode = project.projectCode || "";
|
||||
const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode)
|
||||
kmItem.status = 2;
|
||||
that.xmmcStr = xmmcStr;
|
||||
that.xmmcCode = xmmcCode;
|
||||
@ -55,10 +53,11 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju
|
||||
Reflect.set(judgeUI.projectsObj, xmdm, project)
|
||||
Reflect.set(that.kmItems, xmmcCode || 0, kmItem)
|
||||
break;
|
||||
// 项目结束
|
||||
case 2:
|
||||
}
|
||||
case 2: {
|
||||
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'
|
||||
@ -66,8 +65,9 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju
|
||||
if (isManualProjectIn) {
|
||||
judgeUI.isManualProjectIn = false
|
||||
}
|
||||
const kmItem: KmItem = Reflect.get(that.kmItems, xmmcCode)
|
||||
kmItem.status = 3;
|
||||
//统计必考项目数量
|
||||
//统计必考项目数量
|
||||
that.xmmcStr = '无';
|
||||
that.xmmcCode = '';
|
||||
that.xmdm = '';
|
||||
@ -75,8 +75,8 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju
|
||||
Reflect.set(judgeUI.projectsObj, xmdm, project)
|
||||
Reflect.set(that.kmItems, xmmcCode, kmItem)
|
||||
break;
|
||||
// 扣分
|
||||
case 3:
|
||||
}
|
||||
case 3: {
|
||||
const thisKf = DeductionProjectConversion(`${kf.xmdm}_${kf.kfdm}`, judgeUI.markRuleListObj)
|
||||
const kfObj: MarkRule = {
|
||||
//扣分项目名称
|
||||
@ -103,34 +103,24 @@ export const JudgingFn = async (strData: string, callBack: Function, judgeUI: Ju
|
||||
project.type = (type == '3' || type == '4') ? '4' : '5'
|
||||
Reflect.set(judgeUI.projectsObj, kf.xmdm, project)
|
||||
}
|
||||
}
|
||||
case 4: {
|
||||
that.carztStr = GetCarStatus(carzt);
|
||||
break;
|
||||
// 考试状态
|
||||
case 4:
|
||||
break;
|
||||
// 考试结束
|
||||
case 5:
|
||||
break;
|
||||
// 项目取消
|
||||
case 6:
|
||||
break;
|
||||
// 语音播报和提示
|
||||
case 7:
|
||||
break;
|
||||
// 模拟灯光事件
|
||||
case 8:
|
||||
break;
|
||||
// 车道和路段变化
|
||||
case 9:
|
||||
break;
|
||||
// 预进项目事件
|
||||
case 10:
|
||||
break;
|
||||
// 差分事件
|
||||
case 11:
|
||||
break;
|
||||
default:
|
||||
83
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
|
||||
}
|
||||
case 6: {
|
||||
|
||||
}
|
||||
case 7: {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 考车状态
|
||||
if (event === 4) {
|
||||
}
|
||||
await callBack({
|
||||
//项目名称 考车状态 扣分arr
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
import { testKm2Items, testKm3Items } from '../../mock';
|
||||
import { JudgeConfigObjKmItems, ProjectInfo, ProjectInfos } from '../../model';
|
||||
|
||||
class judgeVariable {
|
||||
public rmndg: 0 | 1 = 0
|
||||
public kmItems: JudgeConfigObjKmItems = {}
|
||||
public xmmcStr: string = ""
|
||||
public xmmcEndCode?: string = ""
|
||||
public xmxh: string = ""
|
||||
public status: string = "开始"
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
public initKmItems(examSubject: string, projectsCenterObj: ProjectInfos) {
|
||||
(examSubject == '2' ? testKm2Items : testKm3Items).forEach(item => {
|
||||
const projectCenterObj: ProjectInfo = Reflect.get(projectsCenterObj, item.code)
|
||||
Reflect.set(this.kmItems, item.code, {
|
||||
code: item.code,
|
||||
status: projectCenterObj === undefined ? 0 : (projectCenterObj.isEnd ? 3 : 1)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const JudgeVariable = new judgeVariable();
|
||||
@ -11,7 +11,7 @@ export class ProcessDataTaskPool {
|
||||
private readonly maxRetries = 5;
|
||||
|
||||
public addTask(dataItem: RegulatoryInterfaceParams): void {
|
||||
console.info(`[Queue] 新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
|
||||
dConsole.log(`[Queue] 新任务已添加: ${JSON.stringify(dataItem)},当前队列长度: ${this.queue.length + 1}`);
|
||||
this.queue.push(dataItem); // 将任务添加到队尾
|
||||
this.triggerProcessing(); // 尝试启动处理流程
|
||||
}
|
||||
@ -22,7 +22,7 @@ export class ProcessDataTaskPool {
|
||||
*/
|
||||
private triggerProcessing(): void {
|
||||
if (this.isProcessing) {
|
||||
console.log('[Queue] 处理器正在运行中,新任务将在稍后被处理。');
|
||||
dConsole.log('[Queue] 处理器正在运行中,新任务将在稍后被处理。');
|
||||
return; // 如果已经在处理,则直接返回,新任务会被正在运行的循环消费掉
|
||||
}
|
||||
// 使用 Promise.resolve().then() 来确保 processQueue 在下一个事件循环中异步执行
|
||||
@ -32,13 +32,13 @@ export class ProcessDataTaskPool {
|
||||
|
||||
private async processQueue(): Promise<void> {
|
||||
this.isProcessing = true;
|
||||
console.log(`[Queue] 启动处理器... 待处理任务数: ${this.queue.length}`);
|
||||
dConsole.log(`[Queue] 启动处理器... 待处理任务数: ${this.queue.length}`);
|
||||
|
||||
while (this.queue.length > 0) {
|
||||
const taskData = this.queue[0]; // 查看队首任务
|
||||
|
||||
try {
|
||||
console.log(`[Queue] 开始处理任务: ${JSON.stringify(taskData)}`);
|
||||
dConsole.log(`[Queue] 开始处理任务: ${JSON.stringify(taskData)}`);
|
||||
// 此方法若成功则正常返回,若永久失败则会抛出错误
|
||||
let obj: WuxiExamType = {
|
||||
xtlb: taskData.xtlb,
|
||||
@ -52,11 +52,11 @@ export class ProcessDataTaskPool {
|
||||
await this.processSingleTaskWithRetries(taskData);
|
||||
// 任务成功,将其从队列中移除
|
||||
this.queue.shift();
|
||||
console.log(`[Queue] ✅ 任务处理成功,已从队列移除。剩余任务: ${this.queue.length}`);
|
||||
dConsole.log(`[Queue] ✅ 任务处理成功,已从队列移除。剩余任务: ${this.queue.length}`);
|
||||
} catch (error) {
|
||||
// 捕获到永久失败的错误
|
||||
console.error(`[Queue] 🔥 致命错误: ${(error as Error).message}`);
|
||||
console.error('[Queue] 队列已停止,后续任务将不会被处理。');
|
||||
dConsole.error(`[Queue] 🔥 致命错误: ${(error as Error).message}`);
|
||||
dConsole.error('[Queue] 队列已停止,后续任务将不会被处理。');
|
||||
|
||||
// (可选)可以在此处清空队列,防止下次意外启动时处理旧任务
|
||||
this.queue = [];
|
||||
@ -67,7 +67,7 @@ export class ProcessDataTaskPool {
|
||||
}
|
||||
|
||||
this.isProcessing = false;
|
||||
console.log('[Queue] 处理器已停止。');
|
||||
dConsole.log('[Queue] 处理器已停止。');
|
||||
}
|
||||
|
||||
private async processSingleTaskWithRetries(taskData: RegulatoryInterfaceParams): Promise<void> {
|
||||
@ -76,16 +76,16 @@ export class ProcessDataTaskPool {
|
||||
const attemptNum = attempt + 1;
|
||||
try {
|
||||
const attemptType = attempt === 0 ? '初次尝试' : `重试 ${attempt}`;
|
||||
console.log(`[Queue] 开始上传 (${attemptType}, 总共第 ${attemptNum} 次): ${JSON.stringify(taskData)}`);
|
||||
dConsole.log(`[Queue] 开始上传 (${attemptType}, 总共第 ${attemptNum} 次): ${JSON.stringify(taskData)}`);
|
||||
const result: WR = await taskpool.execute(uploadWorkerTask, taskData);
|
||||
dConsole.writeProcessData(ProcessDataEnumType.WuxiExam, JSON.stringify(result))
|
||||
if (result.code === 1) {
|
||||
console.log(`[Queue] ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
|
||||
dConsole.log(`[Queue] ✔️ 上传成功 (在第 ${attemptNum} 次尝试)`);
|
||||
return; // 成功,立即返回
|
||||
}
|
||||
console.warn(`[Queue] ❌ 上传失败 (第 ${attemptNum} 次)。响应: ${result.message}`);
|
||||
dConsole.log(`[Queue] ❌ 上传失败 (第 ${attemptNum} 次)。响应: ${result.message}`);
|
||||
} catch (e) {
|
||||
console.error(`[Queue] ❌ TaskPool 执行错误 (第 ${attemptNum} 次): ${e}`);
|
||||
dConsole.error(`[Queue] ❌ TaskPool 执行错误 (第 ${attemptNum} 次): ${e}`);
|
||||
}
|
||||
|
||||
// 如果这是最后一次尝试且依然失败,则不再等待,直接跳出循环去抛出错误
|
||||
@ -117,7 +117,7 @@ export async function uploadWorkerTask(data: RegulatoryInterfaceParams): Promise
|
||||
} catch (err) {
|
||||
// 捕获请求过程中可能出现的异常
|
||||
const error = err as Error;
|
||||
console.error(`[Worker] 上传时发生异常: ${error.message}`);
|
||||
dConsole.error(`[Worker] 上传时发生异常: ${error.message}`);
|
||||
return { code: 20038 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,11 @@ import {
|
||||
DefaultJudgeConfigObj,
|
||||
ExtendType,
|
||||
Gps,
|
||||
JudgeSound,
|
||||
LANE,
|
||||
MarkRule,
|
||||
PLCType,
|
||||
ProcessDataEnumType,
|
||||
ProjectInfo,
|
||||
ProjectInfos,
|
||||
ProjectRoads,
|
||||
@ -18,6 +20,8 @@ import {
|
||||
import { ArrayToByteArray, NumberToByteArray } from '../../utils/Common';
|
||||
import dayTs from '../../utils/Date';
|
||||
import { dConsole } from '../../utils/LogWorker';
|
||||
import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements';
|
||||
import { examJudgeSoundEnd } from './JudgeSDKUtils';
|
||||
|
||||
|
||||
// 中心信号转换
|
||||
@ -852,4 +856,27 @@ export const DeductionProjectConversion = (code: string, markRuleListObj: object
|
||||
export const CurrentProjectConversion = (code: number, projectsObj: object): string => {
|
||||
const project: ProjectInfo = Reflect.get(projectsObj, code)
|
||||
return project?.abbreviation || '通用评判'
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评判语音
|
||||
* @param sound - 评判音频对象
|
||||
* @param avPlayer - 语音播放器实例
|
||||
*/
|
||||
export const PlayJudgeVoice = (sound: JudgeSound, avPlayer: VoiceAnnounce) => {
|
||||
if (sound.type == 1) {
|
||||
avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`], false, () => {
|
||||
examJudgeSoundEnd({
|
||||
xmdm: sound.xmdm, code: sound.code[0], type: sound.type
|
||||
})
|
||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({
|
||||
method: 'examJudgeSoundEnd',
|
||||
itemno: sound.xmdm,
|
||||
code: sound.code[0],
|
||||
type: sound.type,
|
||||
}))
|
||||
})
|
||||
} else {
|
||||
avPlayer?.playAudio([`voice/${sound.code[0]}.mp3`])
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@ import { dConsole } from '../../utils/LogWorker'
|
||||
import { examJudgeMapSetDrawing, examJudgeMapSetScaling } from '../Judge/JudgeSDKUtils'
|
||||
import BlockComponent from './Block'
|
||||
import CoordinateComponent from './Coordinate'
|
||||
|
||||
import libJudgeSdk from '@ohos.judgesdk'
|
||||
|
||||
@Component
|
||||
export default struct TrajectoryViewComponent {
|
||||
@ -175,11 +175,13 @@ struct trajectoryComponent {
|
||||
.height("100%")
|
||||
.onLoad(() => {
|
||||
dConsole.log("开始绘制")
|
||||
examJudgeMapSetDrawing(true)
|
||||
// examJudgeMapSetDrawing(true)
|
||||
libJudgeSdk.examJudgeMapSetDrawing(true)
|
||||
})
|
||||
.onDestroy(() => {
|
||||
dConsole.log("结束绘制")
|
||||
examJudgeMapSetDrawing(false)
|
||||
libJudgeSdk.examJudgeMapSetDrawing(false)
|
||||
})
|
||||
Row() {
|
||||
Image($rawfile('judge/big.png')).width(60).onClick(() => {
|
||||
|
||||
@ -52,9 +52,7 @@ import {
|
||||
WorkerBackMessageType,
|
||||
WR
|
||||
} from '../../model';
|
||||
import { DrivingDataStorage } from '../../utils/business/DrivingDataStorage';
|
||||
import {
|
||||
examCalcGpsDistance,
|
||||
examJudgeArtificialItem,
|
||||
examJudgeArtificialMark,
|
||||
examJudgeBeginExam,
|
||||
@ -170,6 +168,48 @@ export default class Judge {
|
||||
private isExamEnd: boolean
|
||||
// 是否发送udp
|
||||
private isUdpEnd: boolean = false
|
||||
// 处理udp plc信号
|
||||
handleUdp = async (msg: string) => {
|
||||
const stachArr = msg.split(',')
|
||||
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
||||
return
|
||||
}
|
||||
const gpsPart = msg.split("#END$GPS,")[1];
|
||||
const gpsStatus = gpsPart.split(",")[0];
|
||||
if (gpsStatus === "4") {
|
||||
dConsole.log(JudgeTag, "差分状态正常", gpsStatus)
|
||||
this.judgeUI.isDwztRight = true
|
||||
} else {
|
||||
dConsole.log(JudgeTag, "差分状态异常", gpsStatus)
|
||||
this.judgeUI.isDwztRight = false
|
||||
}
|
||||
this.judgeUI.isDwztRight
|
||||
const plcData = await this.getPlcData(msg);
|
||||
// 4.过程数据
|
||||
// await this.fileLog?.setExamJudgeData(JSON.stringify(plcData))
|
||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, 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') || 0;
|
||||
// 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++)
|
||||
}
|
||||
//是否手动结束考试
|
||||
private isManual: boolean = false
|
||||
//UDP服务序列号
|
||||
@ -214,6 +254,60 @@ export default class Judge {
|
||||
dConsole.info(JudgeTag, '过程数据文件上传 end')
|
||||
}
|
||||
private judgeTask: JudgeTask
|
||||
// 检测扣分、结束项目时该项目是否开始
|
||||
checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => {
|
||||
if (xmdm == 20) {
|
||||
return true
|
||||
}
|
||||
const judgeUI = this.judgeUI;
|
||||
const judgeTask = this.judgeTask;
|
||||
const projectsObj: object = this.judgeUI.projectsObj
|
||||
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
|
||||
const isUpload = currentProject.isUpload
|
||||
|
||||
//如果项目没有开始
|
||||
dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload)
|
||||
if (!isUpload) {
|
||||
dConsole.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
|
||||
}
|
||||
}
|
||||
private tempData?: PLCType
|
||||
//实时计算gps经纬度距离
|
||||
handDistance = async () => {
|
||||
@ -222,16 +316,16 @@ export default class Judge {
|
||||
const tJD = ConvertDdmmToDecimalDegrees(this.tempData?.gps?.jd || 0)
|
||||
const tWD = ConvertDdmmToDecimalDegrees(this.tempData?.gps?.wd || 0)
|
||||
if (this.prevJd && dwzt == 4 && jdzt == 3) {
|
||||
const distance = await examCalcGpsDistance({
|
||||
jd1: this.prevJd,
|
||||
wd1: this.prevWd,
|
||||
jd2: tJD,
|
||||
wd2: tWD,
|
||||
h: this.tempData?.gps?.hxj || 1,
|
||||
})
|
||||
// const distance = await examCalcGpsDistance({
|
||||
// jd1: this.prevJd,
|
||||
// wd1: this.prevWd,
|
||||
// jd2: tJD,
|
||||
// wd2: tWD,
|
||||
// h: this.tempData?.gps?.hxj || 1,
|
||||
// })
|
||||
// const distanceClass = AppStorage.get<DistanceClass>('distanceClass')
|
||||
// distanceClass?.setTimeData(Number(((distance / 100).toFixed(2))))
|
||||
DrivingDataStorage.setDrivingProcessData(Number(((distance / 100).toFixed(2))))
|
||||
// DrivingDataStorage.setDrivingProcessData(Number(((distance / 100).toFixed(2))))
|
||||
}
|
||||
this.prevJd = tJD;
|
||||
this.prevWd = tWD;
|
||||
@ -264,47 +358,40 @@ export default class Judge {
|
||||
AppStorage.setOrCreate('msgStr', plc)
|
||||
return tempData
|
||||
}
|
||||
// 处理udp plc信号
|
||||
handleUdp = async (msg: string) => {
|
||||
const stachArr = msg.split(',')
|
||||
if (stachArr[0] != '#DN_GD' || this.isUdpEnd) {
|
||||
return
|
||||
}
|
||||
const gpsPart = msg.split("#END$GPS,")[1];
|
||||
const gpsStatus = gpsPart.split(",")[0];
|
||||
if (gpsStatus === "4") {
|
||||
dConsole.log(JudgeTag, "差分状态正常", gpsStatus)
|
||||
this.judgeUI.isDwztRight = true
|
||||
} else {
|
||||
dConsole.log(JudgeTag, "差分状态异常", gpsStatus)
|
||||
this.judgeUI.isDwztRight = false
|
||||
}
|
||||
this.judgeUI.isDwztRight
|
||||
const plcData = await this.getPlcData(msg);
|
||||
// 4.过程数据
|
||||
// await this.fileLog?.setExamJudgeData(JSON.stringify(plcData))
|
||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, 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') || 0;
|
||||
// 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++)
|
||||
// 处理轨迹plc信号
|
||||
handleTrajectoryUdp = async (strArr: string[]) => {
|
||||
let num = 2;
|
||||
const judgeTimer = setInterval(async () => {
|
||||
const msgStr = strArr[num];
|
||||
if (msgStr == '') {
|
||||
dConsole.info(JudgeTag, '模拟数据考试结束')
|
||||
clearInterval(judgeTimer)
|
||||
this.checkExamIsEnd(true)
|
||||
return
|
||||
}
|
||||
const msg: PLCType = JSON.parse(strArr[num]);
|
||||
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', '')
|
||||
if (msg.method === 'examJudgeArtificialItem') {
|
||||
this.setJudgeItem(msg.itemno, msg.type)
|
||||
}
|
||||
if (msg.method === 'examJudgeArtificialMark') {
|
||||
this.setJudgeItem(msg.itemno, msg.serial)
|
||||
}
|
||||
await examJudgeRealExam(msg)
|
||||
// const bytes = await this.getMessageHeartbeat();
|
||||
// bytes && globalThis.judgeUdp.send(bytes)
|
||||
|
||||
}, 200)
|
||||
// TODO 定时器缺失
|
||||
// globalThis.judgeTimer = judgeTimer;
|
||||
}
|
||||
private isEndTip: boolean = false;
|
||||
//本地轨迹回放地址
|
||||
@ -324,32 +411,6 @@ export default class Judge {
|
||||
const code = await writeObjectOut(JSON.parse(examDataStr), "", this.context);
|
||||
}
|
||||
}
|
||||
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
||||
private lane: LANE = {
|
||||
road: '', num: 0, count: 0
|
||||
}
|
||||
private disConnectNum: number = 0;
|
||||
//调用监管接口
|
||||
sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => {
|
||||
const temp = await writeObjectOut(data, filePath, this.context);
|
||||
dConsole.log(JudgeTag, "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) {
|
||||
dConsole.info('surenjun', '123')
|
||||
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
|
||||
this.judgeUI.disConnectErrorOpen = true
|
||||
}
|
||||
|
||||
this.disConnectNum = 0
|
||||
return temp
|
||||
}
|
||||
// 项目开始接口同步
|
||||
beginProject = async (ksxm: number) => {
|
||||
const carInfo = AppStorage.get<CarInfoType>('carInfo');
|
||||
@ -453,6 +514,32 @@ export default class Judge {
|
||||
UploadRegulatoryCodeConversion('17C54', temp.code || 0)
|
||||
dConsole.info(JudgeTag, '上传照片 end')
|
||||
}
|
||||
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
|
||||
private lane: LANE = {
|
||||
road: '', num: 0, count: 0
|
||||
}
|
||||
private disConnectNum: number = 0;
|
||||
//调用监管接口
|
||||
sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => {
|
||||
const temp = await writeObjectOut(data, filePath, this.context);
|
||||
dConsole.log(JudgeTag, "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) {
|
||||
dConsole.info('surenjun', '123')
|
||||
this.judgeUI.errorMsg = '当前的考试过程信息网络传输异常,程序点击确认将重启!';
|
||||
this.judgeUI.disConnectErrorOpen = true
|
||||
}
|
||||
|
||||
this.disConnectNum = 0
|
||||
return temp
|
||||
}
|
||||
private videoData?: RecordHandleType
|
||||
//当前科目二的考试项目
|
||||
private deductedPopShowTimer: number = 0;
|
||||
@ -566,95 +653,6 @@ export default class Judge {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检测扣分、结束项目时该项目是否开始
|
||||
checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: MarkRule) => {
|
||||
if (xmdm == 20) {
|
||||
return true
|
||||
}
|
||||
const judgeUI = this.judgeUI;
|
||||
const judgeTask = this.judgeTask;
|
||||
const projectsObj: object = this.judgeUI.projectsObj
|
||||
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
|
||||
const isUpload = currentProject.isUpload
|
||||
|
||||
//如果项目没有开始
|
||||
dConsole.info(JudgeTag, 'surenjun isUpload=>', isUpload)
|
||||
if (!isUpload) {
|
||||
dConsole.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
|
||||
}
|
||||
}
|
||||
// 处理轨迹plc信号
|
||||
handleTrajectoryUdp = async (strArr: string[]) => {
|
||||
let num = 2;
|
||||
const judgeTimer = setInterval(async () => {
|
||||
const msgStr = strArr[num];
|
||||
if (msgStr == '') {
|
||||
dConsole.info(JudgeTag, '模拟数据考试结束')
|
||||
clearInterval(judgeTimer)
|
||||
this.checkExamIsEnd(true)
|
||||
return
|
||||
}
|
||||
const msg: PLCType = JSON.parse(strArr[num]);
|
||||
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', '')
|
||||
if (msg.method === 'examJudgeArtificialItem') {
|
||||
this.setJudgeItem(msg.itemno, msg.type)
|
||||
}
|
||||
if (msg.method === 'examJudgeArtificialMark') {
|
||||
this.setJudgeItem(msg.itemno, msg.serial)
|
||||
}
|
||||
await examJudgeRealExam(msg)
|
||||
// const bytes = await this.getMessageHeartbeat();
|
||||
// bytes && globalThis.judgeUdp.send(bytes)
|
||||
|
||||
}, 200)
|
||||
// TODO 定时器缺失
|
||||
// globalThis.judgeTimer = judgeTimer;
|
||||
}
|
||||
|
||||
constructor(judgeUI: JudgeUI) {
|
||||
this.serialIndex = 1;
|
||||
@ -866,7 +864,7 @@ export default class Judge {
|
||||
|
||||
switch (event) {
|
||||
//项目开始
|
||||
case 1:
|
||||
case 1: {
|
||||
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
|
||||
project.type = '2';
|
||||
if (isManualProjectIn) {
|
||||
@ -892,7 +890,7 @@ export default class Judge {
|
||||
Reflect.set(this.judgeUI.projectsObj, xmdm, project)
|
||||
Reflect.set(this.kmItems, xmmcCode || 0, kmItem)
|
||||
break;
|
||||
|
||||
}
|
||||
//项目结束
|
||||
case 2: {
|
||||
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
|
||||
@ -921,7 +919,7 @@ export default class Judge {
|
||||
}
|
||||
|
||||
//扣分
|
||||
case 3:
|
||||
case 3: {
|
||||
const thisKf = this.getKfStr(`${kf.xmdm}_${kf.kfdm}`)
|
||||
const kfObj: MarkRule = {
|
||||
//扣分项目名称
|
||||
@ -939,7 +937,7 @@ export default class Judge {
|
||||
type: kf.type
|
||||
}
|
||||
dConsole.log(JudgeTag, "扣分组装", kfObj)
|
||||
//扣分信息
|
||||
//扣分信息
|
||||
this.kfArr?.push(kfObj)
|
||||
dConsole.log(JudgeTag, "扣分类组装", this.kfArr)
|
||||
this.judgeUI.totalScore += Number(thisKf?.score);
|
||||
@ -950,23 +948,23 @@ export default class Judge {
|
||||
Reflect.set(this.judgeUI.projectsObj, kf.xmdm, project)
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
//考车状态
|
||||
case 4:
|
||||
case 4: {
|
||||
this.carztStr = GetCarStatus(carzt);
|
||||
break;
|
||||
|
||||
}
|
||||
//考试结束
|
||||
case 5:
|
||||
case 5: {
|
||||
this.ksjs = ksjs;
|
||||
// await fileLog?.setExamJudgeData(JSON.stringify({
|
||||
// method: 'examJudgeEndExam'
|
||||
// }))
|
||||
// await fileLog?.setExamJudgeData(JSON.stringify({
|
||||
// method: 'examJudgeEndExam'
|
||||
// }))
|
||||
dConsole.writeProcessData(ProcessDataEnumType.JudgeExamData, JSON.stringify({
|
||||
method: 'examJudgeEndExam'
|
||||
}))
|
||||
break;
|
||||
|
||||
}
|
||||
//项目取消
|
||||
case 6: {
|
||||
dConsole.info(JudgeTag, '项目取消');
|
||||
@ -985,21 +983,21 @@ export default class Judge {
|
||||
}
|
||||
|
||||
//语音播放和提示
|
||||
case 7:
|
||||
case 7: {
|
||||
this.goJudgeVoice(sound)
|
||||
break;
|
||||
|
||||
}
|
||||
//模拟灯光事件
|
||||
case 8:
|
||||
case 8: {
|
||||
this.setMndg(mndg)
|
||||
break;
|
||||
|
||||
}
|
||||
//车道和路段变化
|
||||
case 9:
|
||||
case 9: {
|
||||
this.judgeUI.lane = lane
|
||||
this.lane = lane;
|
||||
break;
|
||||
|
||||
}
|
||||
//预进项目事件
|
||||
case 10: {
|
||||
const param611: JudgeConfigObj = Reflect.get(judgeConfigObj, '611') || ''
|
||||
@ -1126,9 +1124,9 @@ export default class Judge {
|
||||
}
|
||||
|
||||
// 扣分
|
||||
case 3:
|
||||
case 3: {
|
||||
dConsole.info(JudgeTag, 'surenjun', '扣分开始')
|
||||
//扣分时实时播报语音(0-否+1-是)
|
||||
//扣分时实时播报语音(0-否+1-是)
|
||||
const currentKf = kf[kfLen -1];
|
||||
if (JudgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '1') ||
|
||||
(examSubject == '3' && judgeConfigObj['418'] == '1')) {
|
||||
@ -1145,15 +1143,15 @@ export default class Judge {
|
||||
})
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
// 考车状态
|
||||
case 4:
|
||||
break
|
||||
|
||||
// 考试结束
|
||||
case 5:
|
||||
case 5: {
|
||||
dConsole.info(JudgeTag, '考试结束')
|
||||
//关闭录像
|
||||
//关闭录像
|
||||
const singlePlay = AppStorage.get<boolean>('singlePlay')
|
||||
if (!singlePlay && this.videoData) {
|
||||
await endRecordVideo(this.videoData)
|
||||
@ -1163,9 +1161,10 @@ export default class Judge {
|
||||
AppStorage.setOrCreate('isJudge', false)
|
||||
await handEndExam()
|
||||
})
|
||||
// TODO待修改
|
||||
// clearInterval(globalThis.judgeTimer)
|
||||
// TODO待修改
|
||||
// clearInterval(globalThis.judgeTimer)
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user