Revert "feat:评判优化"
This reverts commit 8d489592
This commit is contained in:
		
							parent
							
								
									1f645f3b3a
								
							
						
					
					
						commit
						4bfbfe1516
					
				| @ -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,51 +62,45 @@ 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 thisFileFd = filePathFdObj[filePath]; | ||||
|     try { | ||||
|       if(thisFileFd){ | ||||
|         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.fd | ||||
|         return file.fd | ||||
|       } | ||||
| 
 | ||||
|     } catch (e) { | ||||
|       promptAction.showToast({ | ||||
|         message:`editFile文件失败`+ filePath +JSON.stringify(e), | ||||
|         duration:4000, | ||||
|       }) | ||||
|       console.error(LOGTAG,JSON.stringify(e)) | ||||
|     } | ||||
|   } | ||||
| @ -121,7 +114,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 +252,6 @@ export default class FileUtil { | ||||
|       } | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -31,6 +31,7 @@ import { judgeConfig } from './judgeSDK/utils/judgeConfig'; | ||||
| import FileUtil from '../common/utils/File'; | ||||
| import SignDisplayCom from './compontents/signDisplayCom'; | ||||
| import promptAction from '@ohos.promptAction'; | ||||
| import { voiceService } from '../common/service/voiceService'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -40,6 +41,8 @@ struct Index { | ||||
|   } | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     this.vocObj = new voiceService(async (status, val, next) => { | ||||
|     }); | ||||
|     globalThis.windowClass.setWindowSystemBarEnable([]) | ||||
|     const time = await getCurrentTime() | ||||
| 
 | ||||
| @ -760,6 +763,10 @@ struct Index { | ||||
|                             .height(118 * 0.95) | ||||
|                             .margin({ bottom: 8 }) | ||||
|                             .onClick(() => { | ||||
|                               this.vocObj.playAudio({ | ||||
|                                 type: 1, | ||||
|                                 name: 'button_media.wav' | ||||
|                               }) | ||||
|                               this.setManualProjectFn(index) | ||||
|                             }) | ||||
|                           }) | ||||
| @ -792,6 +799,10 @@ struct Index { | ||||
|             .alignItems(VerticalAlign.Center) | ||||
|             .border({ width: 5, color: '#4D4136', radius: 30 }) | ||||
|             .onClick(() => { | ||||
|               this.vocObj.playAudio({ | ||||
|                 type: 1, | ||||
|                 name: 'button_media.wav' | ||||
|               }) | ||||
|               this.signDisplayComVisible = true | ||||
|             }) | ||||
| 
 | ||||
| @ -827,6 +838,10 @@ struct Index { | ||||
|               .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|               .margin({ bottom: 10 }) | ||||
|               .onClick(() => { | ||||
|                 this.vocObj.playAudio({ | ||||
|                   type: 1, | ||||
|                   name: 'button_media.wav' | ||||
|                 }) | ||||
|                 this.isDeductedPopShow = true | ||||
|               }) | ||||
|             } | ||||
| @ -856,6 +871,10 @@ struct Index { | ||||
|             .backgroundImage($rawfile('judge/anniu_nor.png'), ImageRepeat.NoRepeat) | ||||
|             .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|             .onClick(() => { | ||||
|               this.vocObj.playAudio({ | ||||
|                 type: 1, | ||||
|                 name: 'button_media.wav' | ||||
|               }) | ||||
|               if (this.judgeConfigObj['353'] == '0') { | ||||
|                 this.endPopupVisible = true | ||||
|               } else { | ||||
| @ -919,6 +938,10 @@ struct Index { | ||||
|           .backgroundImage($rawfile('judge/close.png'), ImageRepeat.NoRepeat) | ||||
|           .backgroundImageSize({ width: '33.33%', height: '33.33%' }) | ||||
|           .onClick(() => { | ||||
|             this.vocObj.playAudio({ | ||||
|               type: 1, | ||||
|               name: 'button_media.wav' | ||||
|             }) | ||||
|             this.signDisplayComVisible = false | ||||
|           }) | ||||
|         }.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.6)') | ||||
| @ -1330,10 +1353,11 @@ struct Index { | ||||
|   @State lane: LANE = { road: '', num: 0, count: 0 } | ||||
|   @State roadData: Object = {}; | ||||
|   //定位差分状态时候正常 | ||||
|   @State isDwztRight: boolean = false; | ||||
|   @State isDwztRight: boolean = true; | ||||
|   @State defaultTabIndex: number = 0; | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
|   public kfArrScroller: Scroller = new Scroller() | ||||
|   private vocObj = null; | ||||
|   //档位 | ||||
|   @State dw: string = '' | ||||
|   //速度 | ||||
|  | ||||
| @ -97,8 +97,8 @@ export interface MAPITEMPOINTITEM { | ||||
| } | ||||
| 
 | ||||
| export interface EXAMDATA { | ||||
|   //1:项目开始 2:项目结束 3:扣分 4:考车状态 5:考试结束 6:项目取消 7:语音播放和提示 8:模拟灯光事件 9:车道信息事件 10:预进项目事件
 | ||||
|   event: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ||||
|   //1:项目开始 2:项目结束 3:扣分 4:考车状态 5:考试结束 6:项目取消 7:语音播放和提示 8:模拟灯光事件 9:车道信息事件 10:预进项目事件 11:差分事件
 | ||||
|   event: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | ||||
|   //时间
 | ||||
|   sj: number | ||||
|   //考车状态 -1:后退 0:停车 1:前进
 | ||||
| @ -164,6 +164,9 @@ export interface EXAMDATA { | ||||
|     xmdm:number, | ||||
|     xmxh:string | ||||
|   } | ||||
|   nongps:{ | ||||
|     type:0|1|2|3|4 | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| export interface KSJS { | ||||
|  | ||||
| @ -72,7 +72,6 @@ export default class Judge { | ||||
|     this.kfArr = judgeUI.kfArr | ||||
|     this.xmmcStr = ''; | ||||
|     this.xmmcCode = ''; | ||||
|     this.xmmcEndCode = undefined; | ||||
|     this.carztStr = ''; | ||||
|     this.testKmItems = {}; | ||||
|     // 考试回放配置
 | ||||
| @ -123,7 +122,7 @@ export default class Judge { | ||||
|       strArr = str.split('\n') | ||||
|     } | ||||
|     //日志回调
 | ||||
|     console.info(judgeTag, '1.进入评判入口') | ||||
|     console.info(judgeTag, '1.进入评判入口1') | ||||
|     await examJudgeSetLogCallback(3, async (level, info, len) => { | ||||
|       console.log('评判日志:' + info) | ||||
|       await fileLog.setExamJudgeLogData(info); | ||||
| @ -359,7 +358,7 @@ export default class Judge { | ||||
|   handleRealExam = async (strData, callBack) => { | ||||
|     let examData: EXAMDATA = JSON.parse(strData); | ||||
|     const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,avPlayer,fileLog,judgeUI} = this; | ||||
|     const {carzt,xmks,kf,event,xmjs,xmqx,ksjs,sound,mndg,lane,precast} = examData | ||||
|     const {carzt,xmks,kf,event,xmjs,xmqx,ksjs,sound,mndg,lane,precast,nongps} = examData | ||||
|     const  param512 = (judgeUI.judgeConfigObj['512'] || '').split(','); | ||||
|     //获取项目结束、项目开始代码
 | ||||
|     const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm | ||||
| @ -386,7 +385,6 @@ export default class Judge { | ||||
|         this.xmmcStr = xmmcStr; | ||||
|         this.xmmcCode = xmmcCode; | ||||
|         this.xmmcSingleCode = xmmcSingleCode | ||||
|         this.xmmcEndCode = xmmcCode | ||||
|         this.xmdm = xmdm; | ||||
|         this.xmxh = xmxh; | ||||
|         this.judgeUI.isProjectIn = true | ||||
| @ -484,7 +482,7 @@ export default class Judge { | ||||
|       case 10:{ | ||||
|         const param611 = judgeConfigObj['611'] || ''; | ||||
|         const [f,s] = param611.split('/') | ||||
|         const {xmdm,xmxh} = precast; | ||||
|         const {xmdm} = precast; | ||||
|         const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; | ||||
|         const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; | ||||
|         // if(examSubject == 2 && ((xmdm == 0 && f == 1) || (xmdm == 1 && s == 1) || xmdm == 3)){
 | ||||
| @ -494,13 +492,16 @@ export default class Judge { | ||||
|         this.testKmItems[xmmcCode].status = 2; | ||||
|         this.xmmcStr = xmmcStr; | ||||
|         this.xmmcCode = xmmcCode; | ||||
|         this.xmdm = xmdm; | ||||
|         this.xmxh = xmxh; | ||||
|         this.xmmcSingleCode = xmmcSingleCode; | ||||
|         judgeUI.projectsObj[xmdm].type = '2'; | ||||
|       } | ||||
|         break; | ||||
| 
 | ||||
|     //差分事件
 | ||||
|       case 11:{ | ||||
|         const {type}= nongps | ||||
|         this.checkDwzt(type) | ||||
|       } | ||||
|       default: | ||||
|         break; | ||||
| 
 | ||||
| @ -593,7 +594,6 @@ export default class Judge { | ||||
|               console.info(judgeTag, `项目结束-${xmdm}-${projectsObj[xmdm].name}`) | ||||
|               await endProject(xmdm); | ||||
|               this.xmmcSingleCode = 0; | ||||
|               this.xmmcEndCode = undefined; | ||||
|             }, {isDelay: true}) | ||||
|           } | ||||
|         } | ||||
| @ -760,7 +760,7 @@ export default class Judge { | ||||
|     const carInfo = globalThis.carInfo; | ||||
|     const deviceNo = globalThis.deviceNo; | ||||
|     const { examSubject,plateNo,carNo } = carInfo; | ||||
|     const {judgeUI,getProjectInfo,fileLog,xmmcEndCode,filePath} = this; | ||||
|     const {judgeUI,getProjectInfo,fileLog,xmmcSingleCode,filePath} = this; | ||||
|     const {lsh,idCard,serialNumber,ksdd,projectsObj} = judgeUI | ||||
|     const time = await getCurrentTime(); | ||||
|     const project = getProjectInfo(ksxm); | ||||
| @ -776,11 +776,6 @@ export default class Judge { | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|     console.info('surenjun','开始扣分') | ||||
|     console.info('surenjun ksxm=>',ksxm) | ||||
|     console.info('surenjun commonKsxm=>',commonKsxm) | ||||
|     console.info('surenjun project=>',JSON.stringify(project)) | ||||
| 
 | ||||
|     const data = { | ||||
|       xtlb: '17', jkxlh: serialNumber, jkid: '17C53', | ||||
|       drvexam: { | ||||
| @ -789,7 +784,7 @@ export default class Judge { | ||||
|         ksxm: project == undefined | ||||
|           ? (commonKsxm | ||||
|             ? (projectsObj[commonKsxm].projectCodeCenter) | ||||
|             : (examSubject == 3 ? 30000 : (xmmcEndCode == undefined?10000:xmmcEndCode))) | ||||
|             : (examSubject == 3 ? 30000 : 10000)) | ||||
|           : project.projectCodeCenter , | ||||
|         kfxm: kf.markcatalog, | ||||
|         kfxmmx: `${ksxm},${kf.markserial}`, | ||||
| @ -1487,13 +1482,13 @@ export default class Judge { | ||||
|       const str = await senorToWXDataStr(msg); | ||||
|       usbService.sendUSB(str) | ||||
|     } | ||||
|     this.judgeUI.isDwztRight = (plcData.gps.dwzt == 4 && plcData.gps.jdzt == 3); | ||||
|     // this.judgeUI.isDwztRight = (plcData.gps.dwzt == 4 && plcData.gps.jdzt == 3);
 | ||||
|     const param350 = judgeUI.judgeConfigObj['350'] | ||||
|     //@ts-ignore
 | ||||
|     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); | ||||
|     // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt);
 | ||||
|     if(!isExamEnd){ | ||||
|       await examJudgeRealExam(plcData) | ||||
|     } | ||||
| @ -1579,7 +1574,7 @@ export default class Judge { | ||||
|       const bytes = await this.getMessageHeartbeat(); | ||||
|       bytes && globalThis.judgeUdp.send(bytes) | ||||
| 
 | ||||
|     }, 50) | ||||
|     }, 20) | ||||
| 
 | ||||
|     globalThis.judgeTimer = judgeTimer; | ||||
|   } | ||||
| @ -1620,25 +1615,35 @@ export default class Judge { | ||||
|   } | ||||
| 
 | ||||
|   // 检测差分状态
 | ||||
|   checkDwzt = async (dwzt,jdzt) => { | ||||
|   checkDwzt = async (type) => { | ||||
|     const {avPlayer} = this; | ||||
|     const judgeConfig = this.judgeUI.judgeConfig; | ||||
|     const param499 = judgeConfig['499'] || ''; | ||||
|     if(param499 == '' || param499 == undefined){ | ||||
|       return | ||||
|     } | ||||
|     //10秒内dwzt不为4;
 | ||||
|     const dwztNum = this.dwztNum | ||||
|     if(dwztNum != 0 && (dwztNum % (5 * 10) == 0)  && (param499 !== '' || param499 !== undefined)){ | ||||
|     switch (type){ | ||||
|       case 0: | ||||
|         this.judgeUI.isDwztRight = true; | ||||
|         break; | ||||
| 
 | ||||
|       case 1: | ||||
|         this.judgeUI.dwztErrorVisible = true; | ||||
|         avPlayer.playAudio([`voice/差分状态异常.mp3`],true) | ||||
|     } | ||||
|         setTimeout(()=>{ | ||||
|           router.back() | ||||
|         },3000) | ||||
|         break; | ||||
| 
 | ||||
|     if(dwzt != 4 || jdzt != 3){ | ||||
|       this.dwztNum += 1 | ||||
|     }else{ | ||||
|       this.dwztNum = 0; | ||||
|       this.judgeUI.dwztErrorVisible = false; | ||||
|       case 2: | ||||
|         avPlayer.playAudio([`voice/差分状态异常.mp3`],true); | ||||
| 
 | ||||
|         break; | ||||
|       case 3: | ||||
|         this.judgeUI.dwztErrorVisible = true; | ||||
|         avPlayer.playAudio([`voice/差分状态异常.mp3`],true); | ||||
|         break; | ||||
| 
 | ||||
|       case 4: | ||||
|         this.judgeUI.isDwztRight = false; | ||||
|       //差分异常上报
 | ||||
|         break; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| @ -1659,7 +1664,6 @@ export default class Judge { | ||||
|   private xmmcStr: string | ||||
|   private xmmcCode: string | ||||
|   private xmmcSingleCode: number | ||||
|   private xmmcEndCode?:number | ||||
|   private xmdm: string | number | ||||
|   private xmxh: string | ||||
|   private fileModel: FileModel | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user