fix: 优化扣分bug
This commit is contained in:
		
							parent
							
								
									bc74a62c85
								
							
						
					
					
						commit
						344f74d34b
					
				| @ -323,7 +323,6 @@ struct JudgePage { | ||||
|     const serialNumberArr = (syssetParams as SYSSET[]).filter(sys => sys.v_no === '901'); | ||||
|     dConsole.info(JudgeTag, 'surenjun serialNumberArr' + JSON.stringify(serialNumberArr)) | ||||
|     this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || ''; | ||||
|     // const { isTrajectoryOpen } = judgeConfig | ||||
|     const syssetJudgeConfigArr: SyssetConfig[] = [] | ||||
| 
 | ||||
|     syssetParams.forEach((sys: SYSSET | MASYSSETTableType) => { | ||||
| @ -333,7 +332,6 @@ struct JudgePage { | ||||
|         sys.v_value = (sys as SYSSET).value! | ||||
|       } | ||||
| 
 | ||||
|       // const { v_no, v_value } = sys; | ||||
|       const v_no_num = Number(sys.v_no) | ||||
|       const value = decodeURIComponent(sys.v_value!) | ||||
|       if (v_no_num >= 10 && v_no_num <= 900) { | ||||
| @ -385,7 +383,6 @@ struct JudgePage { | ||||
|         const project_1: ProjectInfo = Reflect.get(this.projectsObj, 1) | ||||
|         project_1.type = kfdm!.length ? '4' : '3'; | ||||
|         Reflect.set(this.projectsObj, 1, project_1) | ||||
| 
 | ||||
|       } | ||||
|       Reflect.set(this.judgeConfigObj, sys.v_no!, value) | ||||
|     }); | ||||
| @ -397,7 +394,6 @@ struct JudgePage { | ||||
|     let systemParms: MA_SYSTEMPARMType[] = sysParam || await GetSyncData<MA_SYSTEMPARMType>('MA_SYSTEMPARM') | ||||
| 
 | ||||
|     let currentParams: RouteParamsType = router.getParams() as RouteParamsType; | ||||
|     // const { carName, carType, examSubject } = this; | ||||
|     //小车车型列表 | ||||
|     const sCarTypes = ['C1', 'C2', 'C5'] | ||||
|     if (this.singlePlay) { | ||||
| @ -407,7 +403,6 @@ struct JudgePage { | ||||
|     let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item); | ||||
|     dConsole.info(JudgeTag, 'surenjun kStringArr', JSON.stringify(kStringArr)) | ||||
|     let isInExam = kStringArr.length > 0; | ||||
|     // const { isTrajectoryOpen } = judgeConfig | ||||
|     let carNo = '', allItems: string[] = []; | ||||
|     systemParms.forEach((systemParm) => { | ||||
|       if (JudgeConfig.isTrajectoryOpen) { | ||||
| @ -485,7 +480,6 @@ struct JudgePage { | ||||
|         Reflect.set(this.projectsCenterObj, txt2, currentProject) | ||||
|         this.projects.push(currentProject); | ||||
|       } | ||||
| 
 | ||||
|       this.systemparmArr.push({ | ||||
|         NO1: Number(systemParm.no1), | ||||
|         NO2: Number(systemParm.no2), | ||||
| @ -495,10 +489,9 @@ struct JudgePage { | ||||
|         TXT3: decodeURIComponent(systemParm.txt3 || ""), | ||||
|       }) | ||||
|     }) | ||||
|     const projects = this.projects; | ||||
|     dConsole.info(JudgeTag, 'surenjun', JSON.stringify(this.ddxkKsxmArr)) | ||||
| 
 | ||||
|     if (!projects.length) { | ||||
|     dConsole.info(JudgeTag, '考试项目', JSON.stringify(this.ddxkKsxmArr)) | ||||
|     dConsole.log(JudgeTag, "考试项目", this.projects) | ||||
|     if (!this.projects.length) { | ||||
|       Prompt.showToast({ | ||||
|         message: '读取数据库信息失败,请重新联网更新!', | ||||
|         duration: 8000 | ||||
| @ -558,6 +551,7 @@ struct JudgePage { | ||||
|     await this.judge.onJudgeFn(async (judgeData: JudgeCallBacData) => { | ||||
|       this.xmmcStr = judgeData.xmmcStr || ""; | ||||
|       this.carztStr = judgeData.carztStr || ""; | ||||
|       dConsole.log(JudgeTag, "扣分", judgeData.kfArr) | ||||
|       this.kfArr = judgeData.kfArr || []; | ||||
|     }); | ||||
|   } | ||||
| @ -652,7 +646,6 @@ struct JudgePage { | ||||
|   async initMapPointItem() { | ||||
|     const pointItemPoints: MA_MAP_POINT_ITEMType[] = await GetSyncData<MA_MAP_POINT_ITEMType>('MA_MAP_POINT_ITEM'); | ||||
|     pointItemPoints.forEach(item => { | ||||
|       // const { point_no, itemno, itemno1, subname } = itemPoint | ||||
|       this.mapPointItemArr.push({ | ||||
|         point_no: Number(item.point_no), | ||||
|         itemno: Number(item.itemno), | ||||
| @ -703,6 +696,7 @@ struct JudgePage { | ||||
| 
 | ||||
|   build() { | ||||
|     Column() { | ||||
|       // 顶部 | ||||
|       Row() { | ||||
|         Row() { | ||||
|           Image($rawfile('judge/signal_logoS.png')).width(120) | ||||
|  | ||||
| @ -9,6 +9,11 @@ export default struct CarLoadingDialog { | ||||
|       Row() { | ||||
|         Text(this.text).fontSize(20) | ||||
|       } | ||||
|     }.width(500).height(500).justifyContent(FlexAlign.Center).alignItems(HorizontalAlign.Center) | ||||
|     } | ||||
|     .width(500) | ||||
|     .height(500) | ||||
|     .justifyContent(FlexAlign.Center) | ||||
|     .alignItems(HorizontalAlign.Center) | ||||
|     .backgroundColor("#fff") | ||||
|   } | ||||
| } | ||||
| @ -184,6 +184,37 @@ 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 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') || 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服务序列号 | ||||
| @ -230,6 +261,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 () => { | ||||
| @ -393,40 +478,8 @@ 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 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') || 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[]) => { | ||||
|     // const { fileLog, setJudgeItem, setJudgeMark, endExam } = this; | ||||
|     let num = 2; | ||||
|     const judgeTimer = setInterval(async () => { | ||||
|       const msgStr = strArr[num]; | ||||
| @ -462,9 +515,9 @@ export default class Judge { | ||||
|   } | ||||
|   //本地轨迹回放地址 | ||||
|   private trajectoryPath: string | ||||
|   //当前科目二的考试项目 | ||||
|   // private currentKm2ItemsObj: any | ||||
|   private isTrajectoryOpen: boolean; | ||||
|   //当前科目二的考试项目 | ||||
|   // 调代理接口是否断网了 | ||||
|   private isJudgeDisConnect: boolean = false; | ||||
|   // 断网数据补传 | ||||
| @ -479,6 +532,33 @@ 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 videoData?: RecordHandleType | ||||
|   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'); | ||||
| @ -582,87 +662,6 @@ export default class Judge { | ||||
|     UploadRegulatoryCodeConversion('17C54', temp.code || 0) | ||||
|     dConsole.info(JudgeTag, '上传照片 end') | ||||
|   } | ||||
|   // 检测扣分、结束项目时该项目是否开始 | ||||
|   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 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, 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 | ||||
|   } | ||||
| 
 | ||||
|   constructor(judgeUI: JudgeUI) { | ||||
|     this.serialIndex = 1; | ||||
| @ -957,8 +956,10 @@ 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); | ||||
|         if (kf.xmdm != 20) { | ||||
|           const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm) | ||||
| @ -1046,7 +1047,7 @@ export default class Judge { | ||||
|     } | ||||
|     await callBack({ | ||||
|       //项目名称   考车状态   扣分arr | ||||
|       xmmcStr: this.xmmcStr, carztStr: this.carztStr, kfArrt: this.kfArr | ||||
|       xmmcStr: this.xmmcStr, carztStr: this.carztStr, kfArr: this.kfArr | ||||
|     }); | ||||
| 
 | ||||
|     //语音播报 | ||||
| @ -1888,7 +1889,7 @@ export default class Judge { | ||||
|     dConsole.info(JudgeTag, '2.注册日志回调完成') | ||||
| 
 | ||||
|     let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); | ||||
|     await fileLog?.setExamJudgeData(JSON.stringify(initInfo)) | ||||
|     // await fileLog?.setExamJudgeData(JSON.stringify(initInfo)) | ||||
|     //相关评判初始化只做一次 | ||||
|     if (!isJudgeInitBool) { | ||||
|       const tempJudge = await examJudgeInit(initInfo); | ||||
| @ -1898,9 +1899,10 @@ export default class Judge { | ||||
|     AppStorage.setOrCreate('isJudge', true) | ||||
|     // 2.评判过程回调 | ||||
|     await examJudgeSetRealExamCallback(async (strData: string, len: number) => { | ||||
|       await fileLog?.setExamJudgeCallbackData(strData) | ||||
|       dConsole.info('评判回调数据', strData) | ||||
|       this.handleRealExam(strData, callBack) | ||||
|       // 评判回调日志 | ||||
|       // await fileLog?.setExamJudgeCallbackData(strData) | ||||
|       dConsole.info(JudgeTag, '评判回调数据', strData) | ||||
|       await this.handleRealExam(strData, callBack) | ||||
|     }) | ||||
| 
 | ||||
|     await examJudgeSetPerformCallback(async (info: string) => { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user