fix: 结束考试问题修复
This commit is contained in:
parent
756ced2469
commit
b2b7950d81
@ -200,6 +200,7 @@ struct JudgePage {
|
||||
})
|
||||
|
||||
async aboutToDisappear() {
|
||||
this.generateExamRecordsDialogController.close()
|
||||
clearInterval(this.mileageTimer)
|
||||
}
|
||||
|
||||
|
||||
@ -261,6 +261,85 @@ 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 () => {
|
||||
const dwzt = this.tempData?.gps?.dwzt || "";
|
||||
const jdzt = this.tempData?.gps?.jdzt || "";
|
||||
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 distanceClass = AppStorage.get<DistanceClass>('distanceClass')
|
||||
// distanceClass?.setTimeData(Number(((distance / 100).toFixed(2))))
|
||||
DrivingDataStorage.setDrivingProcessData(Number(((distance / 100).toFixed(2))))
|
||||
}
|
||||
this.prevJd = tJD;
|
||||
this.prevWd = tWD;
|
||||
}
|
||||
private performInfo?: JudgePerformInfo
|
||||
private isEndTip: boolean = false;
|
||||
private deductedPopShowTimer: number = 0;
|
||||
// 校验考试是否结束
|
||||
checkExamIsEnd =
|
||||
async (isManual?: boolean) => {
|
||||
@ -374,85 +453,6 @@ export default class Judge {
|
||||
}
|
||||
}
|
||||
}
|
||||
private tempData?: PLCType
|
||||
//实时计算gps经纬度距离
|
||||
handDistance = async () => {
|
||||
const dwzt = this.tempData?.gps?.dwzt || "";
|
||||
const jdzt = this.tempData?.gps?.jdzt || "";
|
||||
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 distanceClass = AppStorage.get<DistanceClass>('distanceClass')
|
||||
// distanceClass?.setTimeData(Number(((distance / 100).toFixed(2))))
|
||||
DrivingDataStorage.setDrivingProcessData(Number(((distance / 100).toFixed(2))))
|
||||
}
|
||||
this.prevJd = tJD;
|
||||
this.prevWd = tWD;
|
||||
}
|
||||
private performInfo?: JudgePerformInfo
|
||||
private isEndTip: boolean = false;
|
||||
private deductedPopShowTimer: number = 0;
|
||||
// 检测扣分、结束项目时该项目是否开始
|
||||
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 ksjs?: JudgeKSJS
|
||||
private kfArr?: MarkRule[]
|
||||
//所有的科目考试项目(大车&小车)
|
||||
@ -1325,6 +1325,7 @@ export default class Judge {
|
||||
public handEndExam = async () => {
|
||||
dConsole.info(JudgeTag, '处理考试结束 handEndExam')
|
||||
// this.judgeUI.loadingPopupVisible = true;
|
||||
dConsole.log(JudgeTag, ' 打开车辆loading1')
|
||||
this.judgeUI.generateExamRecordsDialogController.open()
|
||||
// this.judgeUI.endPopupVisible = false;
|
||||
this.judgeUI.endExamDialogController.close()
|
||||
@ -1456,13 +1457,15 @@ export default class Judge {
|
||||
this.isUdpEnd = true;
|
||||
closeAllFiles()
|
||||
// this.judgeUI.loadingPopupVisible = false;
|
||||
dConsole.log(JudgeTag, ' 关闭车辆loading1')
|
||||
this.judgeUI.generateExamRecordsDialogController.close()
|
||||
return
|
||||
}
|
||||
dConsole.info(JudgeTag, '考试结束 end')
|
||||
const param302: string = Reflect.get(judgeConfigObj, '302')
|
||||
// judgeUI.loadingPopupVisible = true;
|
||||
judgeUI.generateExamRecordsDialogController.open()
|
||||
dConsole.log(JudgeTag, ' 打开车辆loading2')
|
||||
// judgeUI.generateExamRecordsDialogController.open()
|
||||
let currentKssycs = '0';
|
||||
let voiceURL = ''
|
||||
if (examSubject == '2') {
|
||||
@ -1563,6 +1566,8 @@ export default class Judge {
|
||||
setTimeout(() => {
|
||||
this.isUdpEnd = true
|
||||
closeAllFiles()
|
||||
dConsole.log(JudgeTag, ' 关闭车辆loading2')
|
||||
this.judgeUI.generateExamRecordsDialogController.close()
|
||||
router.back();
|
||||
}, param302 == '8' ? 3000 : 0)
|
||||
})
|
||||
|
||||
@ -13,43 +13,68 @@ interface QUEUE {
|
||||
type GoTask = (currentTask: QUEUE) => Promise<boolean>
|
||||
|
||||
export default class JudgeTask {
|
||||
//执行任务
|
||||
goTask: GoTask = async (currentTask: QUEUE) => {
|
||||
const fn = currentTask.fn;
|
||||
const delayConfig = currentTask.delayConfig || {
|
||||
isDelay: false, delayTime: 1000
|
||||
}
|
||||
const isDelay = delayConfig.isDelay
|
||||
const delayTime = delayConfig.delayTime
|
||||
|
||||
return false
|
||||
}
|
||||
private queue?: QUEUE[] = []
|
||||
private status: string
|
||||
private queue: QUEUE[] = [];
|
||||
private status: string = 'end';
|
||||
private isExecuting: boolean = false;
|
||||
// 改为迭代方式执行队列
|
||||
executeQueue = async () => {
|
||||
const queue = this.queue;
|
||||
const executeQueue = this.executeQueue
|
||||
if (queue?.length) {
|
||||
for (const currentTask of queue) {
|
||||
await this.goTask(currentTask)
|
||||
this.queue?.shift()
|
||||
await executeQueue()
|
||||
if (this.isExecuting) return;
|
||||
|
||||
this.isExecuting = true;
|
||||
this.status = 'running';
|
||||
|
||||
while (this.queue.length > 0) {
|
||||
const currentTask = this.queue[0];
|
||||
try {
|
||||
await this.goTask(currentTask);
|
||||
} finally {
|
||||
this.queue.shift();
|
||||
}
|
||||
} else {
|
||||
this.status = 'end'
|
||||
}
|
||||
|
||||
this.status = 'end';
|
||||
this.isExecuting = false;
|
||||
}
|
||||
addTask = async (fn: Function, delayConfig?: DelayConfig) => {
|
||||
this.queue?.push({
|
||||
fn, delayConfig
|
||||
this.queue.push({
|
||||
fn,
|
||||
delayConfig
|
||||
});
|
||||
if (this.status == 'end' && this.queue?.length === 1) {
|
||||
|
||||
// 如果当前没有在执行,就启动执行
|
||||
if (!this.isExecuting) {
|
||||
await this.executeQueue();
|
||||
}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.queue = []
|
||||
this.status = 'end'
|
||||
this.queue = [];
|
||||
this.status = 'end';
|
||||
this.isExecuting = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 执行任务
|
||||
goTask: GoTask = async (currentTask: QUEUE) => {
|
||||
try {
|
||||
const fn = currentTask.fn;
|
||||
const delayConfig = currentTask.delayConfig || {
|
||||
isDelay: false, delayTime: 1000
|
||||
}
|
||||
|
||||
// 实际执行任务函数
|
||||
await fn();
|
||||
|
||||
// 处理延迟逻辑
|
||||
if (delayConfig.isDelay && delayConfig.delayTime) {
|
||||
await new Promise<void>(resolve => {
|
||||
setTimeout(resolve, delayConfig.delayTime);
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(TAG, '任务执行失败:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user