1. 新增623参数控制联网模式实施轨迹显示
2. 新增监管结束考试异常,错误提示弹窗显示 3. 优化文件系统:考试结束关闭文件读写
This commit is contained in:
		
							parent
							
								
									cd4affcb6f
								
							
						
					
					
						commit
						4f1a4f894c
					
				| @ -6,7 +6,6 @@ import common from '@ohos.app.ability.common' | ||||
| import fs from '@ohos.file.fs' | ||||
| 
 | ||||
| const LOGTAG = 'LOGTAG' | ||||
| 
 | ||||
| export default class FileUtil{ | ||||
|   private context: common.UIAbilityContext | ||||
|   private wantInfos: Want[] | ||||
| @ -16,6 +15,7 @@ export default class FileUtil { | ||||
|   private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files' | ||||
| 
 | ||||
|   public destFile:string | ||||
|   public filePathFdObj:Object = {} | ||||
| 
 | ||||
|   constructor(wantInfos) { | ||||
|     const {requestPermission} = this; | ||||
| @ -42,20 +42,19 @@ export default class FileUtil { | ||||
|       } catch (e) { | ||||
|         console.info('初始化文件夹失败',path) | ||||
|         promptAction.showToast({ | ||||
|           message: `初始化文件夹失败` + JSON.stringify(e), | ||||
|           message:`初始化文件夹失败`+ folderPath + JSON.stringify(e), | ||||
|           duration:4000, | ||||
|         }) | ||||
|       } | ||||
| 
 | ||||
| 
 | ||||
|     })); | ||||
|     return path; | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
| * @desc 创建并覆盖文件 | ||||
| * | ||||
| */ | ||||
|   public addFile = async (filePath: string, content: string, type?: string, fd?) => { | ||||
|   public addFile = async (filePath:string,content:string,type?:string)=>{ | ||||
|     const { READ_WRITE,CREATE,APPEND }= fs.OpenMode | ||||
|     const isExit = fs.accessSync(filePath); | ||||
|     //文件存在先删除
 | ||||
| @ -63,55 +62,62 @@ export default class FileUtil { | ||||
|       fs.unlinkSync(filePath); | ||||
|     } | ||||
|     try { | ||||
|       let file | ||||
|       if (!fd) { | ||||
|         file = fs.openSync(filePath, READ_WRITE | CREATE); | ||||
|       } | ||||
|       let file = fs.openSync(filePath, READ_WRITE  | CREATE); | ||||
|       //追加写入文件
 | ||||
|       fs.writeSync(file.fd,content) | ||||
|       fs.closeSync(file) | ||||
|       return file.fd | ||||
|       console.error(LOGTAG,'写入文件成功') | ||||
|       return true | ||||
| 
 | ||||
|     }catch (e){ | ||||
|       promptAction.showToast({ | ||||
|         message:`addFile文件失败`+ filePath +JSON.stringify(e), | ||||
|         duration:4000, | ||||
|       }) | ||||
|       console.error(LOGTAG,'写入失败',JSON.stringify(e)) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   public openFileSync = async (filePath) => { | ||||
|     const { READ_WRITE,CREATE,APPEND } = fs.OpenMode | ||||
|     let file = fs.openSync(filePath, READ_WRITE | APPEND | CREATE); | ||||
|     return file | ||||
|   } | ||||
| 
 | ||||
|   public editFileWidthOutOpen(file, content) { | ||||
|     const newStr = content + '\n' | ||||
|     fs.writeSync(file.fd, newStr) | ||||
|     fs.closeSync(file) | ||||
|     console.error(LOGTAG, '写入文件成功') | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|   * @desc 创建或者编辑文件 | ||||
|   * | ||||
|   */ | ||||
|   public editFile = async (filePath:string,content:string,fd?:number)=>{ | ||||
|     const {filePathFdObj} = this; | ||||
|     const { READ_WRITE,CREATE,APPEND }= fs.OpenMode | ||||
|     try { | ||||
|     const newStr =  content + '\n' | ||||
|       if (fd !== undefined) { | ||||
|     const thisFile = filePathFdObj[filePath]; | ||||
|     try { | ||||
|       if(thisFile){ | ||||
|         fs.writeSync(fd,newStr) | ||||
|         return fd | ||||
|         return fd; | ||||
|       }else{ | ||||
|         let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE); | ||||
|         fs.writeSync(file.fd,newStr) | ||||
|         this.filePathFdObj[filePath] = file | ||||
|         return file.fd | ||||
|       } | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       promptAction.showToast({ | ||||
|         message:`editFile文件失败`+ filePath +JSON.stringify(e), | ||||
|         duration:4000, | ||||
|       }) | ||||
|       console.error(LOGTAG,JSON.stringify(e)) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|  * @desc 关闭文件 | ||||
|  * | ||||
|  */ | ||||
|   public closeFile = async (filePath:string)=>{ | ||||
|     const {filePathFdObj} = this; | ||||
|     const thisFile = filePathFdObj[filePath]; | ||||
|     if(thisFile){ | ||||
|       fs.closeSync(thisFile); | ||||
|       console.info(LOGTAG,filePath + '文件关闭成功') | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|   * @desc 读取文件 | ||||
|   * | ||||
| @ -121,7 +127,12 @@ export default class FileUtil { | ||||
|       console.log('strrr',filePath) | ||||
|       const str = await fs.readText(filePath); | ||||
|       return str | ||||
|     } catch (err) { | ||||
|     }catch (e){ | ||||
|       promptAction.showToast({ | ||||
|         message:`读取文件失败`+ filePath +JSON.stringify(e), | ||||
|         duration:4000, | ||||
|       }) | ||||
|       console.log('readFile文件失败'+ filePath +JSON.stringify(e)) | ||||
|       return '' | ||||
|     } | ||||
| 
 | ||||
| @ -254,4 +265,6 @@ export default class FileUtil { | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -10,6 +10,7 @@ import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon'; | ||||
| import {uploadExamMileage} from '../api/judge' | ||||
| import DwztErrorPopup from './compontents/judge/DwztErrorPopup' | ||||
| import {debounce} from '../common/utils/tools' | ||||
| import MsgPopup from './compontents/judge/MsgPopup' | ||||
| 
 | ||||
| import { | ||||
|   CARINFO, | ||||
| @ -186,6 +187,12 @@ struct Index { | ||||
|           name: decodeURI(sys.v_name) | ||||
|         }) | ||||
|       } | ||||
| 
 | ||||
|       //623 考试中是否可以查看轨迹画面(0-否+1-是) | ||||
|       if(sys.v_no == '623'){ | ||||
|         this.syssetParam623 = value == '1'?true:false | ||||
|       } | ||||
| 
 | ||||
|       //科目三应行驶距离参数 | ||||
|       if (sys.v_no == '303') { | ||||
|         this.examMileage = this.examMileage == '0'?(sys.v_value + ''): this.examMileage; | ||||
| @ -930,6 +937,7 @@ struct Index { | ||||
|             showBack: false, | ||||
|             scaleNum: 1.8, | ||||
|             msgStr: this.judge.plcStr || '', | ||||
|             showTrajectory:globalThis.singlePlay ? true : (this.syssetParam623), | ||||
|           }).margin({ top: 100 }) | ||||
| 
 | ||||
|           Row() { | ||||
| @ -977,6 +985,10 @@ struct Index { | ||||
|             this.endPopupVisible = false; | ||||
|           }, | ||||
|           confirmFn: async () => { | ||||
|             if(this.isErrorMsgEnd){ | ||||
|               router.back() | ||||
|               return | ||||
|             } | ||||
|             if (this.judgeConfigObj['344'] == 1) { | ||||
|               Prompt.showToast({ | ||||
|                 message: '考试未结束,不允许手动退出!', | ||||
| @ -991,6 +1003,7 @@ struct Index { | ||||
|             try { | ||||
|               this.judge.checkExamIsEnd(true); | ||||
|             } catch (e) { | ||||
|               this.judge.closeAllFiles() | ||||
|               router.back() | ||||
|             } | ||||
| 
 | ||||
| @ -1005,6 +1018,16 @@ struct Index { | ||||
|         }) | ||||
|       } | ||||
| 
 | ||||
|       if (this.errorMsg){ | ||||
|         MsgPopup({ | ||||
|           title: this.errorMsg, | ||||
|           confirmFn:()=>{ | ||||
|             this.errorMsg = '' | ||||
|             this.isErrorMsgEnd = true; | ||||
|           }, | ||||
|         }) | ||||
|       } | ||||
| 
 | ||||
|       if(this.dwztErrorVisible){ | ||||
|         DwztErrorPopup({ | ||||
|           title:'当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框', | ||||
| @ -1324,6 +1347,7 @@ struct Index { | ||||
|   @State xldm: string = '' | ||||
|   //监管接口序列号 | ||||
|   @State serialNumber: number = 0 | ||||
|   @State syssetParam623: boolean = false; | ||||
|   @State carType: string = '' | ||||
|   @State carName: string = '' | ||||
|   @State isDeductedPopShow: boolean = false | ||||
| @ -1369,4 +1393,6 @@ struct Index { | ||||
|   @State dwztErrorVisible: boolean = false; | ||||
|   @State popTimer:number =0; | ||||
|   @State carlist:string= '' | ||||
|   @State errorMsg: string = '' | ||||
|   @State isErrorMsgEnd: boolean = false | ||||
| } | ||||
|  | ||||
| @ -9,6 +9,7 @@ import { GlobalConfig } from '../../config/index' | ||||
| @Component | ||||
| export default struct SignDisplayCom { | ||||
|   @State showBack: boolean = false | ||||
|   @Prop showTrajectory:boolean = false | ||||
|   @State scaleNum: number = 1 | ||||
|   @State msg: string = '' | ||||
|   @State signArr: Array<any> = [] | ||||
| @ -50,7 +51,7 @@ export default struct SignDisplayCom { | ||||
| 
 | ||||
|             }) | ||||
| 
 | ||||
|             if (!this.showBack) { | ||||
|             if (this.showTrajectory) { | ||||
|               Row() { | ||||
|                 Text('实时轨迹').fontColor(this.active == 1 ? '#FFAD33' : '#e7cba3').fontSize(20 * this.ratio) | ||||
|               } | ||||
|  | ||||
							
								
								
									
										23
									
								
								entry/src/main/ets/pages/compontents/judge/MsgPopup.ets
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								entry/src/main/ets/pages/compontents/judge/MsgPopup.ets
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| 
 | ||||
| @Component | ||||
| export default struct  MsgPopup{ | ||||
|   constructor() { | ||||
|     super() | ||||
|   } | ||||
| 
 | ||||
|   private title:string = '' | ||||
|   private confirmFn:(event?: ClickEvent) => void | ||||
| 
 | ||||
|   build(){ | ||||
|     Column(){ | ||||
|       Column(){ | ||||
|         Text(this.title).fontSize(36).margin({bottom:20}).lineHeight(50) | ||||
|         Row(){}.height(100) | ||||
|         Row(){ | ||||
|           Text('确定').backgroundImage($rawfile('judge/end-btn.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width(250).height(95).fontSize(28).fontColor('#FFF').textAlign(TextAlign.Center).onClick(this.confirmFn) | ||||
|         }.margin({top:20}) | ||||
|       }.width('65%').height('70%').padding(30).backgroundColor('#E6E3DF').borderRadius(38).position({y:'12%',x:'17.5%'}).justifyContent(FlexAlign.Center) | ||||
| 
 | ||||
|     }.width('100%').height('100%').position({y:0}).backgroundColor('rgba(0,0,0,0.7)') | ||||
|   } | ||||
| } | ||||
| @ -95,6 +95,7 @@ export default class Judge { | ||||
|           : ( projectCenterObj.isEnd ? 3 : 1 ) | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|     console.info(judgeTag+'testKmItems',JSON.stringify(this.testKmItems)) | ||||
|     this.isExamEnd = false; | ||||
|   } | ||||
| @ -170,7 +171,7 @@ export default class Judge { | ||||
|     await fileLog.setExamJudgeData(beginExamInfo) | ||||
|     await examJudgeBeginExam(beginExamInfo); | ||||
|     console.info(judgeTag, '6.开始考试注册完成') | ||||
|     avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.WAV' : 'voice/监管成功.mp3']) | ||||
|     avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) | ||||
| 
 | ||||
|     if(!globalThis.singlePlay){ | ||||
|       this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`) | ||||
| @ -542,7 +543,8 @@ export default class Judge { | ||||
|       judgeUI, | ||||
|       checkExamIsEnd, | ||||
|       checkProjectIsStart, | ||||
|       lane | ||||
|       lane, | ||||
|       closeAllFiles | ||||
|     } = this; | ||||
| 
 | ||||
|     const {projectsObj,judgeConfigObj,examSubject,examMileage,jl,isAllProjectsEnd} = judgeUI; | ||||
| @ -640,6 +642,7 @@ export default class Judge { | ||||
|         judgeTask.addTask(async () => { | ||||
|           console.info(judgeTag, '考试结束 start') | ||||
|           globalThis.isJudge = false; | ||||
|           closeAllFiles() | ||||
|           await handEndExam(ksjs) | ||||
|         }) | ||||
|         clearInterval(globalThis.judgeTimer) | ||||
| @ -1062,10 +1065,11 @@ export default class Judge { | ||||
| 
 | ||||
|     if(code != 1){ | ||||
|       avPlayer.playAudio(['voice/监管失败.mp3']) | ||||
|       this.judgeUI.errorMsg = decodeURIComponent(message) | ||||
|       this.isUdpEnd = true | ||||
|       router.back(); | ||||
|       return | ||||
|     } | ||||
| 
 | ||||
|     console.info(judgeTag, '考试结束 end') | ||||
|     const param302 = judgeConfigObj['302']; | ||||
|     judgeUI.loadingPopupVisible = true; | ||||
| @ -1566,7 +1570,7 @@ export default class Judge { | ||||
|       const msgStr = strArr[num]; | ||||
|       if(msgStr == ''){ | ||||
|         console.info(judgeTag, '模拟数据考试结束') | ||||
|         // globalThis.windowClass.setWindowSystemBarEnable(['navigation'])
 | ||||
|         globalThis.windowClass.setWindowSystemBarEnable(['navigation']) | ||||
|         clearInterval(judgeTimer) | ||||
|         this.checkExamIsEnd(true) | ||||
|         return | ||||
| @ -1664,6 +1668,11 @@ export default class Judge { | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   closeAllFiles = ()=>{ | ||||
|     this.fileLog.closeAllFiles() | ||||
|   } | ||||
| 
 | ||||
|   public plcStr: string | ||||
|   private judgeUI | ||||
|   private fileLog | ||||
|  | ||||
| @ -14,8 +14,8 @@ interface StuInfo{ | ||||
| } | ||||
| 
 | ||||
| const LOGTAG = 'LOGTAG' | ||||
| export default class FileLog { | ||||
| 
 | ||||
| export default class FileLog { | ||||
|   //后续文件路径待替换
 | ||||
|   private fileUtil: FileUtil | ||||
|   private stuInfo: StuInfo | ||||
| @ -105,6 +105,14 @@ export default class FileLog { | ||||
|     this.fourAndOneLogDataBytesFd = await fileUtil.editFile(`${folderPath}/four_one_log_byte_data.txt`, str, fourAndOneLogDataBytesFd); | ||||
|   } | ||||
| 
 | ||||
|   //关闭所有文件写入
 | ||||
|   public closeAllFiles = async () => { | ||||
|     const {fileUtil,folderPath,fourAndOneLogDataFd} = this; | ||||
|     ['exam_progress_data', 'wuxi_exam_data', 'wuxi_progress_data', 'plc_data', 'judge_exam_data', 'judge_progress_callback_data', 'judge_log_data', 'four_one_log_data', 'four_one_log_byte_data'].forEach(path => { | ||||
|       fileUtil.closeFile(`${folderPath}/${path}.txt`); | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|   // 无锡所轨迹数据
 | ||||
|   public setExamLineData = async (plcStr) => { | ||||
|     const {fileUtil,folderPath,examLineDataFd} = this; | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								entry/src/main/resources/rawfile/judge/ksks.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								entry/src/main/resources/rawfile/judge/ksks.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user