fix: 距离不对的问题解决
This commit is contained in:
		
							parent
							
								
									e3d6ab8e24
								
							
						
					
					
						commit
						80dd24fd64
					
				| @ -16,7 +16,7 @@ export const JudgeConfig: JudgeConfigType = { | |||||||
|   //是否开启拍照 |   //是否开启拍照 | ||||||
|   isPhotoOpen: true, |   isPhotoOpen: true, | ||||||
|   //扣分语音是否强制开启 |   //扣分语音是否强制开启 | ||||||
|   kfVoiceOpen: false, |   kfVoiceOpen: true, | ||||||
|   //忽略的考试项目 |   //忽略的考试项目 | ||||||
|   ignoreProjects: [], |   ignoreProjects: [], | ||||||
|   // 是否忽略考试前熄火、车门检查 |   // 是否忽略考试前熄火、车门检查 | ||||||
|  | |||||||
| @ -96,6 +96,7 @@ export default class EntryAbility extends UIAbility { | |||||||
|       hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); |       hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|     this.createFiles(); |     this.createFiles(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -550,6 +550,7 @@ export interface CARINFO { | |||||||
|   FLAG: string, |   FLAG: string, | ||||||
|   BK1: string, |   BK1: string, | ||||||
|   BK2: string |   BK2: string | ||||||
|  |   X_MCH: string, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface KmItem { | export interface KmItem { | ||||||
|  | |||||||
| @ -4,8 +4,14 @@ import router from '@ohos.router'; | |||||||
| import { HomeTag, InitTableTag, JudgeConfig } from '../config'; | import { HomeTag, InitTableTag, JudgeConfig } from '../config'; | ||||||
| import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; | import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; | ||||||
| import { BaseInfoType } from '../model/Common'; | import { BaseInfoType } from '../model/Common'; | ||||||
| import { CarInfoType, InitializeTheCentralTableType, MASYSSETTableType, TimeSynchronizationRspBody } from '../model'; | import { | ||||||
| import { CreateAlbum, GetCarInfo, GetDeviceInfo, SetCurrentTime } from './Index/utils'; |   CarInfoType, | ||||||
|  |   ES_CARINFOType, | ||||||
|  |   InitializeTheCentralTableType, | ||||||
|  |   MASYSSETTableType, | ||||||
|  |   TimeSynchronizationRspBody | ||||||
|  | } from '../model'; | ||||||
|  | import { CheckNetUntilConnected, CreateAlbum, GetCarInfo, GetDeviceInfo, SetCurrentTime } from './Index/utils'; | ||||||
| import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation'; | import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation'; | ||||||
| import { BusinessError } from '@ohos.base'; | import { BusinessError } from '@ohos.base'; | ||||||
| import { delPic } from '../utils/Video'; | import { delPic } from '../utils/Video'; | ||||||
| @ -19,7 +25,6 @@ import Prompt from '@system.prompt'; | |||||||
| import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker'; | import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker'; | ||||||
| import { dConsole } from '../utils/LogWorker'; | import { dConsole } from '../utils/LogWorker'; | ||||||
| import CarLoadingComponent from './Index/Loading'; | import CarLoadingComponent from './Index/Loading'; | ||||||
| import { ObtainNetworkCameraImages } from '../api/networkCamera'; |  | ||||||
| 
 | 
 | ||||||
| @Entry | @Entry | ||||||
| @Component | @Component | ||||||
| @ -64,7 +69,8 @@ struct Index { | |||||||
| 
 | 
 | ||||||
|   async aboutToAppear() { |   async aboutToAppear() { | ||||||
|     dConsole.log("权限首页 aboutToAppear") |     dConsole.log("权限首页 aboutToAppear") | ||||||
|     this.base64Img = await ObtainNetworkCameraImages() || "" |     const result = await GetSyncData<ES_CARINFOType>("ES_CARINFO") | ||||||
|  |     dConsole.log(HomeTag, "读取carinfo", result) | ||||||
|     this.ratio = AppStorage.get<BaseInfoType>('baseInfo')?.ratio || 1.4 |     this.ratio = AppStorage.get<BaseInfoType>('baseInfo')?.ratio || 1.4 | ||||||
|     this.angle = 0 |     this.angle = 0 | ||||||
|     AppStorage.set('lsh', '1111111111111') |     AppStorage.set('lsh', '1111111111111') | ||||||
| @ -80,7 +86,8 @@ struct Index { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async onPageShow(): Promise<void> { |   async onPageShow(): Promise<void> { | ||||||
|     dConsole.log("权限首页 onPageShow2") |     dConsole.log("权限首页 onPageShow") | ||||||
|  |     await CheckNetUntilConnected() | ||||||
|     if (!this.isPlay) { |     if (!this.isPlay) { | ||||||
|       this.avPlayer.playAudio(['welcome.wav']) |       this.avPlayer.playAudio(['welcome.wav']) | ||||||
|       this.isPlay = true |       this.isPlay = true | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| import common from '@ohos.app.ability.common'; | import common from '@ohos.app.ability.common'; | ||||||
| import { GlobalConfig } from '../../config'; | import { GlobalConfig, HomeTag } from '../../config'; | ||||||
| import Prompt from '@system.prompt'; | import Prompt from '@system.prompt'; | ||||||
| import { | import { | ||||||
|   ApiResponseType, |   ApiResponseType, | ||||||
| @ -19,6 +19,8 @@ import { VideoConfigData } from '../../mock'; | |||||||
| import FileUtils from '../../utils/FileUtils'; | import FileUtils from '../../utils/FileUtils'; | ||||||
| import { FileHelper } from '../../utils/FileHelp'; | import { FileHelper } from '../../utils/FileHelp'; | ||||||
| import { dConsole } from '../../utils/LogWorker'; | import { dConsole } from '../../utils/LogWorker'; | ||||||
|  | import connection from '@ohos.net.connection'; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| //获取设备信息 | //获取设备信息 | ||||||
| export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> { | export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> { | ||||||
| @ -42,19 +44,28 @@ export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<s | |||||||
| 
 | 
 | ||||||
| // 获取车辆信息 | // 获取车辆信息 | ||||||
| export async function GetCarInfo(): Promise<CarInfoType> { | export async function GetCarInfo(): Promise<CarInfoType> { | ||||||
|  | 
 | ||||||
|   let date = new Date(); |   let date = new Date(); | ||||||
|   let params: ObtainCarExamInfoParams = { |   let params: ObtainCarExamInfoParams = { | ||||||
|     time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), |     time: dayTs(date).format("YYYY-MM-DD HH:mm:ss"), | ||||||
|     deviceNo: AppStorage.get<string>('deviceNo') || "" |     deviceNo: AppStorage.get<string>('deviceNo') || "" | ||||||
|   }; |   }; | ||||||
|   let res: ApiResponseType = await obtainCarExamInfo(params) |   try { | ||||||
|   dConsole.log("90", res) |     let res: ApiResponseType = await obtainCarExamInfo(params) | ||||||
|   if (res.obtainCarExamInfoRsp && res.obtainCarExamInfoRsp.body) { |     dConsole.log("90", res) | ||||||
|     const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! |     if (res.obtainCarExamInfoRsp && res.obtainCarExamInfoRsp.body) { | ||||||
|     carInfo.plateNo = decodeURIComponent(carInfo.plateNo) |       const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! | ||||||
|     dConsole.log("Worker received message car", JSON.stringify(carInfo)) |       carInfo.plateNo = decodeURIComponent(carInfo.plateNo) | ||||||
|     AppStorage.setOrCreate('carInfo', carInfo) |       dConsole.log("Worker received message car", JSON.stringify(carInfo)) | ||||||
|     return carInfo |       AppStorage.setOrCreate('carInfo', carInfo) | ||||||
|  |       return carInfo | ||||||
|  |     } | ||||||
|  |   } catch (e) { | ||||||
|  |     dConsole.error(HomeTag, "获取考车信息错误", JSON.stringify(e)) | ||||||
|  |     setTimeout(() => { | ||||||
|  |       dConsole.log(HomeTag, "延迟获取考车信息") | ||||||
|  |       GetCarInfo() | ||||||
|  |     }, 1000) | ||||||
|   } |   } | ||||||
|   return {} |   return {} | ||||||
| } | } | ||||||
| @ -141,3 +152,35 @@ export function CreateAlbum(fileHelper: FileHelper) { | |||||||
|   fileHelper.createAlbum(date); |   fileHelper.createAlbum(date); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const RETRY_INTERVAL_MS = 3000; | ||||||
|  | 
 | ||||||
|  | export async function CheckNetUntilConnected(): Promise<void> { | ||||||
|  |   return new Promise(async (resolve, reject) => { | ||||||
|  |     const doCheck = async () => { | ||||||
|  |       try { | ||||||
|  |         let netHandle: connection.NetHandle = await connection.getDefaultNet(); | ||||||
|  |         // getDefaultNet().netId 在网络连接正常时会大于0 | ||||||
|  |         // 在没有默认网络时,getDefaultNet()可能会抛出异常或者返回netId为0的NetHandle | ||||||
|  |         // 最新的OpenHarmony API中,推荐使用connection.getNetCapabilities(netHandle) | ||||||
|  |         // 或 connection.hasDefaultNet() 来更准确判断网络状态 | ||||||
|  | 
 | ||||||
|  |         let hasDefaultNet: boolean = await connection.hasDefaultNet(); | ||||||
|  | 
 | ||||||
|  |         if (hasDefaultNet && netHandle && netHandle.netId > 0) { | ||||||
|  |           dConsole.log(HomeTag, "网络通畅"); | ||||||
|  |           resolve(); // 网络通畅,解决Promise | ||||||
|  |         } else { | ||||||
|  |           dConsole.log(HomeTag, "网络不通畅,等待 " + RETRY_INTERVAL_MS / 1000 + " 秒后重试..."); | ||||||
|  |           setTimeout(doCheck, RETRY_INTERVAL_MS); // 网络不通畅,继续重试 | ||||||
|  |         } | ||||||
|  |       } catch (error) { | ||||||
|  |         dConsole.log(HomeTag, "网络不通畅,等待 " + RETRY_INTERVAL_MS / 1000 + " 秒后重试..."); | ||||||
|  |         setTimeout(doCheck, RETRY_INTERVAL_MS); // 即使出错,也继续重试 | ||||||
|  |       } | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     // 首次执行检查 | ||||||
|  |     doCheck(); | ||||||
|  |   }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -282,6 +282,7 @@ struct JudgePage { | |||||||
|       FLAG: carInfo.flag!, |       FLAG: carInfo.flag!, | ||||||
|       BK1: carInfo.bk1!, |       BK1: carInfo.bk1!, | ||||||
|       BK2: carInfo.bk2!, |       BK2: carInfo.bk2!, | ||||||
|  |       X_MCH: carInfo.x_mch!, | ||||||
|     }) |     }) | ||||||
|     dConsole.info(JudgeTag, 'surenjun =>carinfoArrr', JSON.stringify(this.carinfoArr)) |     dConsole.info(JudgeTag, 'surenjun =>carinfoArrr', JSON.stringify(this.carinfoArr)) | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -75,6 +75,7 @@ function getDataFn(config: EnvironmentConfigurationType) { | |||||||
|         // 替换data的第28位 |         // 替换data的第28位 | ||||||
|         dataArray[28] = res[9].toString(); |         dataArray[28] = res[9].toString(); | ||||||
|         data = dataArray.join(","); |         data = dataArray.join(","); | ||||||
|  |         console.log(SerialPortTag, "档位", res[9].toString()) | ||||||
|       } |       } | ||||||
|       console.log(SerialPortTag, "处理完的档位信号", data) |       console.log(SerialPortTag, "处理完的档位信号", data) | ||||||
|       workerPort.postMessage( |       workerPort.postMessage( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user