Compare commits
	
		
			6 Commits
		
	
	
		
			bd62ff705d
			...
			86a905e949
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 86a905e949 | |||
| 0855162b43 | |||
| 3b013f451c | |||
| cb86c2b903 | |||
| 1ad5458a6b | |||
| b62a22b25d | 
							
								
								
									
										51
									
								
								entry/src/main/ets/common/utils/GetDistance.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								entry/src/main/ets/common/utils/GetDistance.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,51 @@ | ||||
| import FileUtil from './File' | ||||
| import {getCurrentTime} from './tools' | ||||
| 
 | ||||
| const LOGTAG = 'GetDistance' | ||||
| export default class GetDistance { | ||||
| 
 | ||||
|   //后续文件路径待替换
 | ||||
|   private fileUtil: FileUtil | ||||
|   public folderPath: string | ||||
|   public timeStr: string | ||||
|   public totalDistance: number | ||||
|   public date: string | ||||
| 
 | ||||
|   constructor(context) { | ||||
|     const fileUtil = new FileUtil(context) | ||||
|     this.fileUtil = fileUtil | ||||
|   } | ||||
| 
 | ||||
|   // 设置文件夹
 | ||||
|   public initFolder= async () => { | ||||
|     const {fileUtil} = this | ||||
|     const time = await getCurrentTime() | ||||
|     const folderPath = await fileUtil.initFolder(`/车辆行驶距离统计`); | ||||
|     console.info('surenjun folderPath=>' ,folderPath); | ||||
|     const date = time.split(' ')[0].split('-').join('_') | ||||
|     const timeStr = time.split(' ')[1] | ||||
|     this.timeStr = timeStr | ||||
|     this.folderPath = folderPath; | ||||
|     this.totalDistance = 0; | ||||
|     this.date = date; | ||||
|     await fileUtil.editFile( | ||||
|       `${folderPath}/${date}.txt`,`程序启动时间:${timeStr} 累计行驶距离:${this.totalDistance}m` | ||||
|     ); | ||||
|     return folderPath | ||||
|   } | ||||
| 
 | ||||
|   // 过程文件数据
 | ||||
|   public setTimeData = async (str:number) => { | ||||
|     const {fileUtil,folderPath,timeStr,date,totalDistance} = this; | ||||
|     const content = await fileUtil.readFile(`${folderPath}/${date}.txt`) || ''; | ||||
|     console.info('surenjun',str) | ||||
|     const contentArr = content.split('\n').filter(item => item) | ||||
|     console.info('surenjun contentArr',JSON.stringify(contentArr)) | ||||
|     this.totalDistance += str | ||||
|     contentArr[contentArr.length - 1] = `程序启动时间:${timeStr} 累计行驶距离:${this.totalDistance}m`+ '\n' | ||||
|     console.info('surenjun',contentArr.join('\n')) | ||||
|     await fileUtil.addFile( | ||||
|       `${folderPath}/${date}.txt`,contentArr.join('\n') | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -4,7 +4,8 @@ import {  testKm2Items,testKm3Items } from '../../pages/judgeSDK/dataTest/index' | ||||
| import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; | ||||
| import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; | ||||
| import { convertGpsCoord2 } from '../utils/tools'; | ||||
| 
 | ||||
| import {examCalcGpsDistance} from '../../pages/judgeSDK/api' | ||||
| import GetDistance from './GetDistance' | ||||
| export const initJudgeUdp = async () => { | ||||
|   globalThis.serialIndex = 0; | ||||
|   globalThis.udpIndex = 0; | ||||
| @ -19,6 +20,8 @@ export const initJudgeUdp = async () => { | ||||
|     lightLineUdp.send(arrBlueBuffer); | ||||
|   } | ||||
|   globalThis.lightLineUdp = lightLineUdp | ||||
| 
 | ||||
|   let [prevJd,preWd] = [0,0] | ||||
|   globalThis.udpClient.onMessage_1(async (msg) => { | ||||
|     const stachArr = msg.split(',') | ||||
|     if (stachArr[0] != '#DN_GD') { | ||||
| @ -28,7 +31,22 @@ export const initJudgeUdp = async () => { | ||||
|     const isJudge = globalThis.isJudge; | ||||
|     if (udpIndex % 5 === 0 && !isJudge) { | ||||
|       const bytes = await getMessageHeartbeat(msg); | ||||
|       const msgArr = msg.split(','); | ||||
|       const jd = convertGpsCoord2(msgArr[96]*1); | ||||
|       const wd =  convertGpsCoord2(msgArr[95]*1 || 0); | ||||
|       udp.send(bytes) | ||||
|       if(prevJd){ | ||||
|         const distance = await examCalcGpsDistance({ | ||||
|           jd1:prevJd, | ||||
|           wd1:preWd, | ||||
|           jd2:jd, | ||||
|           wd2:wd, | ||||
|           h:msgArr[90]*1 || 1, | ||||
|         }) | ||||
|         globalThis.distanceClass.setTimeData(Math.floor(distance/100)) | ||||
|       } | ||||
|       prevJd = jd; | ||||
|       preWd = wd; | ||||
|     } | ||||
|     globalThis.udpIndex += 1 | ||||
|   }) | ||||
|  | ||||
| @ -28,12 +28,12 @@ export default class EntryAbility extends UIAbility { | ||||
|         globalThis.examinerInfo = {} | ||||
|         globalThis.deviceNo = ''; | ||||
|         globalThis.hasAuth = false | ||||
|         // globalThis.version = '2022.08.13.01'
 | ||||
|         // globalThis.judgeVersion = '2022.12.05.1'
 | ||||
|         globalThis.version = '2022.08.13.01'//洛阳
 | ||||
|         globalThis.judgeVersion = '2022.12.05.1' | ||||
|         // globalThis.version = '2022.12.05.1'
 | ||||
|         // globalThis.judgeVersion = '2022.08.13.01'
 | ||||
|         globalThis.version = '2024.11.22.14'//济南
 | ||||
|         globalThis.judgeVersion = '2024.11.22.14' | ||||
|         // globalThis.version = '2024.11.22.14'//济南
 | ||||
|         // globalThis.judgeVersion = '2024.11.22.14'
 | ||||
|         globalThis.videoVersion= '1.0' | ||||
|         // globalThis.version = '2023.12.13.01'
 | ||||
|         // globalThis.judgeVersion = '2023.09.30.1'
 | ||||
|  | ||||
| @ -17,8 +17,7 @@ import promptAction from '@ohos.promptAction' | ||||
| import { voiceService } from '../common/service/voiceService'; | ||||
| import errorMsgDialog from './compontents/errorMsgDialog' | ||||
| import { getSyncData } from '../common/service/initable'; | ||||
| import { GlobalConfig } from '../config/index' | ||||
| 
 | ||||
| import GetDistance from '../common/utils/GetDistance' | ||||
| @Entry | ||||
| @Component | ||||
| struct Index { | ||||
| @ -103,7 +102,9 @@ struct Index { | ||||
|                 if (this.loading) { | ||||
|                   return | ||||
|                 } | ||||
| 
 | ||||
|                 setTimeout(() => { | ||||
|                   this.angle = 360 | ||||
|                 }, 1000) | ||||
|                 this.angle = 0 | ||||
|                 if (!globalThis.timeInfo) { | ||||
|                   globalThis.type='1' | ||||
| @ -116,7 +117,6 @@ struct Index { | ||||
|                   this.loading = false | ||||
|                   return | ||||
|                 } | ||||
| 
 | ||||
|                 if (!globalThis.carInfo) { | ||||
|                   promptAction.showToast({ | ||||
|                     message: `车辆信息接口获取失败`, | ||||
| @ -124,14 +124,10 @@ struct Index { | ||||
|                   }); | ||||
|                   globalThis.type='1' | ||||
|                   AppStorage.SetOrCreate('errorMsg', 1); | ||||
|                   console.log('testXMLToJSONInWorker5',JSON.stringify(globalThis.carInfo)) | ||||
| 
 | ||||
|                   globalThis.title='车辆信息接口获取失败' | ||||
|                   this.loading = false | ||||
|                   return | ||||
|                 } | ||||
|                 console.log('testXMLToJSONInWorker6',JSON.stringify(globalThis.carInfo)) | ||||
| 
 | ||||
|                 this.testXMLToJSONInWorker() | ||||
| 
 | ||||
| 
 | ||||
| @ -146,31 +142,6 @@ struct Index { | ||||
|                 if (this.loading) { | ||||
|                   return | ||||
|                 } | ||||
|                 if (!globalThis.timeInfo) { | ||||
|                   globalThis.type='1' | ||||
|                   AppStorage.SetOrCreate('errorMsg', 1); | ||||
|                   globalThis.title='时间同步接口连接失败' | ||||
|                   promptAction.showToast({ | ||||
|                     message: `时间同步接口连接失败`, | ||||
|                     duration: 3000 | ||||
|                   }); | ||||
|                   this.loading = false | ||||
|                   return | ||||
|                 } | ||||
| 
 | ||||
|                 if (!globalThis.carInfo) { | ||||
|                   promptAction.showToast({ | ||||
|                     message: `车辆信息接口获取失败`, | ||||
|                     duration: 3000 | ||||
|                   }); | ||||
|                   globalThis.type='1' | ||||
|                   AppStorage.SetOrCreate('errorMsg', 1); | ||||
|                   console.log('testXMLToJSONInWorker5',JSON.stringify(globalThis.carInfo)) | ||||
| 
 | ||||
|                   globalThis.title='车辆信息接口获取失败' | ||||
|                   this.loading = false | ||||
|                   return | ||||
|                 } | ||||
|                 //判断数据库是否有表数据,有则直接跳转,没有则读取本地数据 | ||||
|                 getSyncData('MA_SYSSET').then(data => { | ||||
|                   console.log('datadata', JSON.stringify(data)) | ||||
| @ -179,13 +150,10 @@ struct Index { | ||||
|                       url: 'pages/UserInfo', | ||||
|                     }, router.RouterMode.Single) | ||||
|                   } else { | ||||
| 
 | ||||
|                     this.loading = true | ||||
|                     this.testXMLToJSONInWorker() | ||||
|                   } | ||||
|                 }) | ||||
| 
 | ||||
| 
 | ||||
|                 ; | ||||
|                 }); | ||||
|               }) | ||||
|           } | ||||
|           Image($r('app.media.index_zj')) | ||||
| @ -318,37 +286,36 @@ struct Index { | ||||
|     .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|   } | ||||
| 
 | ||||
|   aboutToAppear() { | ||||
|   async aboutToAppear() { | ||||
|     this.dialogVisiable = false | ||||
|     this.angle = 0 | ||||
|     this.loading = false | ||||
|     globalThis.lsh = '1111111111111' | ||||
| 
 | ||||
|     const distanceClass = new GetDistance(globalThis.context) | ||||
|     await distanceClass.initFolder() | ||||
|     globalThis.distanceClass = distanceClass | ||||
|   } | ||||
| 
 | ||||
|   async testXMLToJSONInWorker() { | ||||
|     if (this.loading) { | ||||
|       return | ||||
|     } | ||||
|     console.log('globalThis.timeInfo11111',JSON.stringify(globalThis.timeInfo),'globalThis.carInfo',JSON.stringify(globalThis.carInfo)) | ||||
| 
 | ||||
|     let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ts'); | ||||
|     const param = { | ||||
|       singlePlay: this.isSingle, | ||||
|       carId: globalThis.carInfo?.carId, | ||||
|       examinationRoomId: globalThis.carInfo?.examinationRoomId, | ||||
|       judgeVersion: globalThis.judgeVersion, | ||||
|       shellVersion: globalThis.version, | ||||
|       paraKdid: globalThis.timeInfo?.paraKdid, | ||||
|       mode: globalThis.timeInfo?.mode, | ||||
|       host: globalThis.host, | ||||
|       centerHost: globalThis.timeInfo?.url, | ||||
|       context: this.context, | ||||
|       host: globalThis.host, | ||||
|       centerHost: globalThis.timeInfo.url, | ||||
|       singlePlay: globalThis.singlePlay | ||||
|     } | ||||
|     console.log('globalThis.timeInfo',JSON.stringify(globalThis.timeInfo),'globalThis.carInfo',JSON.stringify(globalThis.carInfo)) | ||||
|     this.loading = true | ||||
|     setTimeout(() => { | ||||
|       this.angle = 360 | ||||
|     }, 1000) | ||||
|     workerInstance.postMessage(param); | ||||
|     workerInstance.onmessage = (e: MessageEvents): void => { | ||||
|       console.log("baoyihu after postMessage :", JSON.stringify(e.data)); | ||||
| @ -398,11 +365,11 @@ struct Index { | ||||
| 
 | ||||
|     console.log('globalThis.singlePlay', globalThis.singlePlay) | ||||
|     if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { | ||||
|       globalThis.singlePlay = false | ||||
|       this.vocObj.playAudio({ | ||||
|         type: 1, | ||||
|         name: 'welcome.wav' | ||||
|       }) | ||||
|       globalThis.singlePlay = false | ||||
|     } | ||||
|     this.isSingle = globalThis.singlePlay | ||||
|     this.loading = false | ||||
| @ -445,7 +412,7 @@ struct Index { | ||||
|   } | ||||
| 
 | ||||
|   async initParams() { | ||||
|     deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress+'/PLC/') | ||||
|     deleteAllFIleLog() | ||||
|     //设置plc udp 同步requesthost | ||||
|     await getUDP(this.context, false) | ||||
|     this.loading = false | ||||
|  | ||||
| @ -205,8 +205,8 @@ export async function examCalcGpsDistance(param:{ | ||||
|   h:number | ||||
| }){ | ||||
|   const {jd1,wd1,jd2,wd2,h} = param | ||||
|   const temp = libJudgeSdk.examJudgeSoundEnd(jd1,wd1,jd2,wd2,h); | ||||
|   return await handle(temp,'examCalcGpsDistance') | ||||
|   const temp = libJudgeSdk.examCalcGpsDistance(jd1,wd1,jd2,wd2,h); | ||||
|   return await temp; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -294,7 +294,7 @@ export default class Judge { | ||||
|   //处理评判过程回调
 | ||||
|   handleRealExam = async (strData, callBack) => { | ||||
|     let examData: EXAMDATA = JSON.parse(strData); | ||||
|     const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,avPlayer,judgeUI} = this; | ||||
|     const {getDqxmStr,getKfStr,goJudgeVoice,setMndg,avPlayer,fileLog,judgeUI} = this; | ||||
|     const {carzt,xmks,kf,event,xmjs,xmqx,ksjs,sound,mndg,lane} = examData | ||||
|     const  param512 = (judgeUI.judgeConfigObj['512'] || '').split(','); | ||||
|     //获取项目结束、项目开始代码
 | ||||
| @ -379,6 +379,9 @@ export default class Judge { | ||||
|     //考试结束
 | ||||
|       case 5: | ||||
|         this.ksjs = ksjs; | ||||
|         await fileLog.setExamJudgeData({ | ||||
|           method: 'examjudgeEndExam', | ||||
|         }) | ||||
|         break; | ||||
| 
 | ||||
|     //项目取消
 | ||||
| @ -756,78 +759,79 @@ export default class Judge { | ||||
|   } | ||||
| 
 | ||||
|   // 校验考试是否结束
 | ||||
|   checkExamIsEnd = async (isManual?: boolean) => { | ||||
|     const {judgeUI,avPlayer,isExamEnd,isEndTip} = this; | ||||
|     const {isAllProjectsEnd,examSubject,singlePlay,totalScore,judgeConfigObj,passingScore} = judgeUI; | ||||
|   checkExamIsEnd = | ||||
|     async (isManual?: boolean) => { | ||||
|       const {judgeUI,avPlayer,isExamEnd,isEndTip} = this; | ||||
|       const {isAllProjectsEnd,examSubject,singlePlay,totalScore,judgeConfigObj,passingScore} = judgeUI; | ||||
| 
 | ||||
|     if (isExamEnd) { | ||||
|       return | ||||
|     } | ||||
|     //及格分
 | ||||
|     let passingGrade = passingScore | ||||
|     if (isManual) { | ||||
|       if (isAllProjectsEnd) { | ||||
|         // 考试合格
 | ||||
|         if (totalScore >= passingGrade) { | ||||
|           // 考试合格
 | ||||
|           await examJudgeEndExam(); | ||||
|           this.isExamEnd = true | ||||
|         } | ||||
|       } else { | ||||
|         // 考试不合格
 | ||||
|         await examJudgeEndExam() | ||||
|         this.isExamEnd = true | ||||
|       if (isExamEnd) { | ||||
|         return | ||||
|       } | ||||
|       this.isManual = true | ||||
| 
 | ||||
|     } else { | ||||
|       //单机模式
 | ||||
|       if (singlePlay) { | ||||
|         console.info(judgeTag + ' isAllProjectsEnd => ',isAllProjectsEnd) | ||||
|       //及格分
 | ||||
|       let passingGrade = passingScore | ||||
|       if (isManual) { | ||||
|         if (isAllProjectsEnd) { | ||||
|           // 考试合格
 | ||||
|           if (totalScore >= passingGrade) { | ||||
|             // 考试合格
 | ||||
|             await examJudgeEndExam(); | ||||
|             this.isExamEnd = true | ||||
|           } | ||||
|         } else { | ||||
|           // 考试不合格
 | ||||
|           await examJudgeEndExam() | ||||
|           this.isExamEnd = true | ||||
|         } | ||||
|         this.isManual = true | ||||
| 
 | ||||
|       } else { | ||||
|         const param302 = judgeConfigObj['302']; | ||||
|         const param342 = judgeConfigObj['342']; | ||||
|         const param512 = (judgeConfigObj['512'] || '').split(','); | ||||
|         //成绩不合格
 | ||||
|         if (totalScore < passingGrade) { | ||||
|           //科目三不合格报靠边停车
 | ||||
|           if(examSubject == 3 && param302 ==1){ | ||||
|             avPlayer.playAudio([`voice/考试结束.mp3`]); | ||||
|             return | ||||
|           } | ||||
|           await examJudgeEndExam() | ||||
|           this.isExamEnd = true | ||||
|           return | ||||
|         } | ||||
|         //成绩合格
 | ||||
|         if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { | ||||
| 
 | ||||
|           //考试合格自动退出
 | ||||
|           if(examSubject == 3 && param302 == 4){ | ||||
|         //单机模式
 | ||||
|         if (singlePlay) { | ||||
|           console.info(judgeTag + ' isAllProjectsEnd => ',isAllProjectsEnd) | ||||
|           if (isAllProjectsEnd) { | ||||
|             await examJudgeEndExam() | ||||
|             this.isExamEnd = true | ||||
|             return | ||||
|           } | ||||
| 
 | ||||
|           if (examSubject == 3 && (param342 == 0 || param342 == 2) && (param302 != 6 || param302 != 7 || param302 != 8)) { | ||||
|             if(param512[7] != 0){ | ||||
|               avPlayer.playAudio(['voice/综合评判.mp3']) | ||||
|               this.judgeUI.isDeductedPopShow = true | ||||
|               this.judgeUI.defaultTabIndex = 1 | ||||
|               this.isEndTip = true | ||||
|         } else { | ||||
|           const param302 = judgeConfigObj['302']; | ||||
|           const param342 = judgeConfigObj['342']; | ||||
|           const param512 = (judgeConfigObj['512'] || '').split(','); | ||||
|           //成绩不合格
 | ||||
|           if (totalScore < passingGrade) { | ||||
|             //科目三不合格报靠边停车
 | ||||
|             if(examSubject == 3 && param302 ==1){ | ||||
|               avPlayer.playAudio([`voice/考试结束.mp3`]); | ||||
|               return | ||||
|             } | ||||
|           } else { | ||||
|             await examJudgeEndExam() | ||||
|             this.isExamEnd = true | ||||
|             return | ||||
|           } | ||||
|           //成绩合格
 | ||||
|           if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { | ||||
| 
 | ||||
|             //考试合格自动退出
 | ||||
|             if(examSubject == 3 && param302 == 4){ | ||||
|               await examJudgeEndExam() | ||||
|               this.isExamEnd = true | ||||
|               return | ||||
|             } | ||||
| 
 | ||||
|             if (examSubject == 3 && (param342 == 0 || param342 == 2) && (param302 != 6 || param302 != 7 || param302 != 8)) { | ||||
|               if(param512[7] != 0){ | ||||
|                 avPlayer.playAudio(['voice/综合评判.mp3']) | ||||
|                 this.judgeUI.isDeductedPopShow = true | ||||
|                 this.judgeUI.defaultTabIndex = 1 | ||||
|                 this.isEndTip = true | ||||
|               } | ||||
|             } else { | ||||
|               await examJudgeEndExam() | ||||
|               this.isExamEnd = true | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // 处理考试结束
 | ||||
|   public handEndExam = async (ksjs: KSJS) => { | ||||
|  | ||||
| @ -95,8 +95,10 @@ class AVPlayer { | ||||
|       let fdPath = await playSrc.open('r') | ||||
|       let audioPlayer = media.createAudioPlayer() | ||||
|       // console.info('surenjun fdPath=>',fdPath)
 | ||||
|       console.info(TAG,'audioPlayer => 准备加载资源播放') | ||||
|       audioPlayer.on('dataLoad', () => { | ||||
|         this.voiceStatus = 'playing' | ||||
|         console.info(TAG,'audioPlayer => 播放资源开始') | ||||
|         audioPlayer.play() | ||||
|       }) | ||||
|       return new Promise(async (resolve)=>{ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user