fix: 小红球udp结束考试
This commit is contained in:
		
							parent
							
								
									2ada59b81f
								
							
						
					
					
						commit
						6eb48607ba
					
				| @ -39,6 +39,8 @@ export interface JudgeData { | ||||
|   judgeExamEnd?: boolean | ||||
|   performInfo?: JudgePerformInfo, | ||||
|   business?: JudgeUDPData | ||||
|   remoteType?: number | ||||
|   remoteData?: number[] | ||||
| } | ||||
| 
 | ||||
| export interface CenterData { | ||||
| @ -72,6 +74,10 @@ export enum WorkerBackMessageType { | ||||
|   ObtainUdpData = 'obtainUdpData', | ||||
|   // 中心消息 | ||||
|   CenterUdpData = 'centerUdpData', | ||||
|   // 远程开始考试 | ||||
|   RemoteStartExam = 'remoteStartExam', | ||||
|   // 远程结束考试 | ||||
|   RemoteEndExam = 'remoteEndExam' | ||||
| } | ||||
| 
 | ||||
| export interface LogWorkerMessage { | ||||
|  | ||||
| @ -36,7 +36,9 @@ import { | ||||
|   SYSSET, | ||||
|   SyssetConfig, | ||||
|   SYSTEM_PARAM, | ||||
|   User | ||||
|   User, | ||||
|   WorkerBackMessage, | ||||
|   WorkerBackMessageType | ||||
| } from '../model'; | ||||
| import { GetSyncData } from '../utils/table/Operation'; | ||||
| import dayTs from '../utils/Date'; | ||||
| @ -52,6 +54,7 @@ import OperatingAreaComponent from './Judge/components/OperatingArea'; | ||||
| import { GetIsExitManualProject } from './Judge/utils'; | ||||
| import { InitMapPoint, InitMapPointItem } from './Judge/TableUtils'; | ||||
| import JudgeBusiness from './Judge/JudgeBusiness'; | ||||
| import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker'; | ||||
| 
 | ||||
| 
 | ||||
| @Entry | ||||
| @ -201,14 +204,8 @@ export struct JudgePage { | ||||
|     // dConsole.log("车道信号变化1", this.laneSignal) | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     this.generateExamRecordsDialogController.close() | ||||
|     this.signalTrajectoryDialogController.close() | ||||
|     // this.judgeBusiness.close() | ||||
|     clearInterval(this.mileageTimer) | ||||
|   } | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     DifferentialAndSignal.onMsg(this.onEndExam) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.singlePlay = AppStorage.get<boolean>('singlePlay')! | ||||
|     this.startFullTime = dayTs().format("YYYYMMDDHHmmss"); | ||||
| @ -223,6 +220,14 @@ export struct JudgePage { | ||||
|     await this.initJudge(); | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear() { | ||||
|     this.generateExamRecordsDialogController.close() | ||||
|     this.signalTrajectoryDialogController.close() | ||||
|     // this.judgeBusiness.close() | ||||
|     clearInterval(this.mileageTimer) | ||||
|     DifferentialAndSignal.offMsg(this.onEndExam) | ||||
|   } | ||||
| 
 | ||||
|   //初始化相关数据库表 | ||||
|   async initDb() { | ||||
|     this.examSubject = this.carInfo.examSubject!; | ||||
| @ -789,5 +794,13 @@ export struct JudgePage { | ||||
|     } | ||||
|     .height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) | ||||
|   } | ||||
| 
 | ||||
|   private onEndExam = (msg: string) => { | ||||
|     let result: WorkerBackMessage = JSON.parse(msg) | ||||
|     if (result.type === WorkerBackMessageType.RemoteEndExam) { | ||||
|       dConsole.info("lixiao", msg) | ||||
|       this.judgeBusiness.JudgeEnd(true) | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -751,6 +751,7 @@ export class BaseJudge { | ||||
|   } | ||||
| 
 | ||||
|   async judgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { | ||||
|     dConsole.info("lixiao", 'surenjun 收到远程结束考试消息3') | ||||
|     const isAllProjectsEnd = judgeUI.isAllProjectsEnd | ||||
|     const examSubject = judgeUI.examSubject | ||||
|     const singlePlay = judgeUI.singlePlay | ||||
|  | ||||
| @ -9,7 +9,7 @@ import { | ||||
|   RecordHandleType, | ||||
|   WorkerBackMessage, | ||||
|   WorkerBackMessageType, | ||||
|   WorkerMessageDataType, | ||||
|   WorkerMessageDataType | ||||
| } from '../../model' | ||||
| import FileUtils from '../../utils/FileUtils' | ||||
| import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements' | ||||
| @ -115,7 +115,7 @@ export default class JudgeBusiness { | ||||
|     this.judgeBusiness.JudgeStart(callBack, this.judgeUI, this) | ||||
|     //   处理PLC数据 | ||||
|     // 处理实时udp里的plc信号 | ||||
|     DifferentialAndSignal.onMsg(this.onObdCallback) | ||||
|     DifferentialAndSignal.onMsg(this.onUdpMessageCallback) | ||||
|     this.JudgeEnd() | ||||
|   } | ||||
| 
 | ||||
| @ -126,14 +126,15 @@ export default class JudgeBusiness { | ||||
| 
 | ||||
|   // 结束考试 | ||||
|   public JudgeEnd(isManual?: boolean) { | ||||
|     dConsole.info("lixiao", 'surenjun 收到远程结束考试消息1') | ||||
|     this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual) | ||||
|   } | ||||
| 
 | ||||
|   close() { | ||||
|     DifferentialAndSignal.offMsg(this.onObdCallback) | ||||
|     DifferentialAndSignal.offMsg(this.onUdpMessageCallback) | ||||
|   } | ||||
| 
 | ||||
|   private onObdCallback = (data: string) => { | ||||
|   private onUdpMessageCallback = (data: string) => { | ||||
|     const result: WorkerBackMessage = JSON.parse(data) | ||||
|     if (result.type === WorkerBackMessageType.ObtainUdpData) { | ||||
|       this.HandlePLCData(result.data as string) | ||||
|  | ||||
| @ -330,6 +330,7 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl { | ||||
|   } | ||||
| 
 | ||||
|   public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { | ||||
|     dConsole.info("lixiao", 'surenjun 收到远程结束考试消息2') | ||||
|     super.judgeEnd(judgeUI, that, isManual) | ||||
|   }; | ||||
| } | ||||
|  | ||||
| @ -43,7 +43,6 @@ import { CheckSignal, GetCurrentUserKeyValue, InitializeExamProcessData } from ' | ||||
| import dayTs from '../utils/Date'; | ||||
| import { GetCurrentTime, GetPhotoBase64, NumberToByteArray } from '../utils/Common'; | ||||
| import DB from '../utils/DbSql'; | ||||
| import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; | ||||
| import { StartEndExamTag, StartExamTag, UserInfoTag } from '../config'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import HeaderComponent from './compontents/Header'; | ||||
| @ -271,6 +270,11 @@ struct UserInfoPage { | ||||
|               this.currentUser = this.dataList[0] | ||||
|               this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" | ||||
|               AppStorage.setOrCreate('lsh', this.currentUser.lsh) | ||||
|               DifferentialAndSignal.sendMsg({ | ||||
|                 type: WorkerMessageDataType.SetExamData, | ||||
|                 data: { lsh: this.currentUser.lsh } | ||||
|               }) | ||||
| 
 | ||||
|             }, 200) | ||||
|           } else { | ||||
|             this.currentUser = EmptyCandidateObject | ||||
| @ -308,17 +312,13 @@ struct UserInfoPage { | ||||
|     // initJudgeUdp() | ||||
|     // TODO UDP更改 | ||||
|     //监听远程开始考试 | ||||
|     JudgeEmitterInstance.onBeginExam(async () => { | ||||
|       dConsole.log('surenjun', 'userInfo收到UdpEvent事件') | ||||
|       if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { | ||||
|         await this.prePareSCZB() | ||||
|       } else { | ||||
|         await this.prePareExam() | ||||
|       } | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async onPageHide(): Promise<void> { | ||||
|     DifferentialAndSignal.offMsg(this.heartMsg) | ||||
|   } | ||||
| 
 | ||||
|   async aboutToDisappear(): Promise<void> { | ||||
|     // CenterUDPBusinessInstance.offMsg(this.onCenterMsg) | ||||
|     // DifferentialAndSignal.offMsg(this.onCenterMsg) | ||||
| @ -361,6 +361,10 @@ struct UserInfoPage { | ||||
|         this.examinerLoginInfo.ksyh = res.ksy1sfzmhm | ||||
|         AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo) | ||||
|         AppStorage.setOrCreate('lsh', res.lsh) | ||||
|         DifferentialAndSignal.sendMsg({ | ||||
|           type: WorkerMessageDataType.SetExamData, | ||||
|           data: { lsh: res.lsh } | ||||
|         }) | ||||
|         // const { examSubject } = this.carInfo; | ||||
|         dConsole.log("开始考试2") | ||||
|         if (this.singlePlay) { | ||||
| @ -388,6 +392,10 @@ struct UserInfoPage { | ||||
|         this.currentUser = this.list[0] | ||||
|         this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" | ||||
|         AppStorage.setOrCreate('lsh', this.currentUser.lsh) | ||||
|         DifferentialAndSignal.sendMsg({ | ||||
|           type: WorkerMessageDataType.SetExamData, | ||||
|           data: { lsh: this.currentUser.lsh } | ||||
|         }) | ||||
|       }, 200) | ||||
| 
 | ||||
|       // promptAction.showToast({ | ||||
| @ -463,6 +471,10 @@ struct UserInfoPage { | ||||
|     this.callBackFlag = false | ||||
|     AppStorage.setOrCreate('lsh', this.lsh) | ||||
|     AppStorage.setOrCreate('statue', 2) | ||||
|     DifferentialAndSignal.sendMsg({ | ||||
|       type: WorkerMessageDataType.SetExamData, | ||||
|       data: { lsh: this.currentUser.lsh } | ||||
|     }) | ||||
|     // this.currentUser = EmptyCandidateObject | ||||
|     this.numCount = 0 | ||||
|     if (this.singlePlay) { | ||||
| @ -763,6 +775,10 @@ struct UserInfoPage { | ||||
|             this.currentUser = user.length ? user[0] : this.dataList[0] | ||||
|             this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" | ||||
|             AppStorage.setOrCreate('lsh', this.currentUser.lsh) | ||||
|             DifferentialAndSignal.sendMsg({ | ||||
|               type: WorkerMessageDataType.SetExamData, | ||||
|               data: { lsh: this.currentUser.lsh } | ||||
|             }) | ||||
|             this.examinerLoginInfo.ksyh = this.currentUser.ksy1sfzmhm | ||||
|             AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo) | ||||
|           }, 200) | ||||
| @ -847,22 +863,29 @@ struct UserInfoPage { | ||||
| 
 | ||||
|   onCenterMsg = (msg: string) => { | ||||
|     let result = JSON.parse(msg) as WorkerBackMessage | ||||
|     if (result.type !== WorkerBackMessageType.CenterUdpData) { | ||||
|       return | ||||
|     } | ||||
|     let val = result.data as CenterCallBackMsgType | ||||
|     dConsole.info("中心回执", val) | ||||
|     if (val.id == 32) { | ||||
|       AppStorage.setOrCreate('signNum', val.body[1]) | ||||
|       if (val.body[0] == 7) { | ||||
|         //缺考处理 | ||||
|         this.getqkFn() | ||||
|         this.signNum = val.body[1] | ||||
| 
 | ||||
|     if (result.type === WorkerBackMessageType.RemoteStartExam) { | ||||
|       dConsole.log('surenjun', 'userInfo收到开始考试事件') | ||||
|       if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { | ||||
|         this.prePareSCZB() | ||||
|       } else { | ||||
|         this.prePareExam() | ||||
|       } | ||||
|     } else if (result.type === WorkerBackMessageType.CenterUdpData) { | ||||
|       let val = result.data as CenterCallBackMsgType | ||||
|       if (val.id == 32) { | ||||
|         AppStorage.setOrCreate('signNum', val.body[1]) | ||||
|         if (val.body[0] == 7) { | ||||
|           //缺考处理 | ||||
|           this.getqkFn() | ||||
|           this.signNum = val.body[1] | ||||
|         } | ||||
|       } else if (val.id == 42) { | ||||
|         //收到中心缺考确认消息 | ||||
|         this.qkFn() | ||||
|       } | ||||
|     } else if (val.id == 42) { | ||||
|       //收到中心缺考确认消息 | ||||
|       this.qkFn() | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   async getExaminationItemFn() { | ||||
| @ -1076,6 +1099,10 @@ struct UserInfoPage { | ||||
|                 } | ||||
|                 this.currentUser = EmptyCandidateObject | ||||
|                 AppStorage.setOrCreate('lsh', item.lsh) | ||||
|                 DifferentialAndSignal.sendMsg({ | ||||
|                   type: WorkerMessageDataType.SetExamData, | ||||
|                   data: { lsh: item.lsh } | ||||
|                 }) | ||||
|                 setTimeout(() => { | ||||
|                   this.currentUser = item | ||||
|                   this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" | ||||
|  | ||||
| @ -97,7 +97,7 @@ class CenterUDPBusiness { | ||||
|     return this.udp.close() | ||||
|   } | ||||
| 
 | ||||
|   private dealMsg(msg: ArrayBuffer): CenterCallBackMsgType { | ||||
|   private dealMsg = (msg: ArrayBuffer): CenterCallBackMsgType => { | ||||
|     let arr: number[] = [] | ||||
|     let dataView = new DataView(msg) | ||||
|     for (let i = 0; i < dataView?.byteLength; ++i) { | ||||
|  | ||||
| @ -2,7 +2,6 @@ | ||||
| import worker, { MessageEvents } from '@ohos.worker'; | ||||
| import { WorkerTag } from '../../config'; | ||||
| import { CarInfoType, EnvironmentConfigurationType, WorkerMessage, WorkerMessageDataType } from '../../model'; | ||||
| import { MsgExt } from '../UdpUtils'; | ||||
| 
 | ||||
| class differentialAndSignal { | ||||
|   private workerInstance = new worker.ThreadWorker("entry/ets/workers/DifferentialCorrection.ets") | ||||
| @ -95,8 +94,7 @@ class differentialAndSignal { | ||||
|   getMessage() { | ||||
|     this.workerInstance.onmessage = (e: MessageEvents): void => { | ||||
|       if (e.data) { | ||||
|         // console.log(WorkerTag, "Worker 收到消息: " + e.data); | ||||
|         // console.log(WorkerTag, "Worker 目前监听数量: " + this.events.length.toString()); | ||||
|         console.log(WorkerTag, "lixiao", "Worker 收到消息: " + e.data); | ||||
|         this.events.forEach((callback) => { | ||||
|           callback(e.data); | ||||
|         }); | ||||
|  | ||||
| @ -21,6 +21,7 @@ import { SerialNumberInstance } from '../SerialNumber'; | ||||
| import { GetCenterProjectStatus, GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils'; | ||||
| import { testKm2Items, testKm3Items } from '../../mock'; | ||||
| import { dConsole } from '../LogWorker'; | ||||
| import { CenterUDPBusinessInstance } from './CenterUdpBusiness'; | ||||
| 
 | ||||
| 
 | ||||
| const Tag = "JudgeUdpBusiness" | ||||
| @ -246,26 +247,21 @@ class JudgeUdpBusiness { | ||||
|   } | ||||
| 
 | ||||
|   //申请远程扣分查询 | ||||
|   askKf(directives: number) { | ||||
|   askKf(directives: number, lsh: number) { | ||||
|     // TODO | ||||
|     // CenterUDPBusinessInstance.sendData({ | ||||
|     //   id: 35, | ||||
|     //   list: [directives], | ||||
|     //   carNo: this.carInfo.carNo!, | ||||
|     //   placeId: this.carInfo.examinationRoomId!, | ||||
|     // }) | ||||
|     CenterUDPBusinessInstance.sendMsgExt(35, [directives], lsh) | ||||
|     console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`) | ||||
|   } | ||||
| 
 | ||||
|   askStopExam(directives: number, lsh: number) { | ||||
|     CenterUDPBusinessInstance.sendMsgExt(38, [directives], lsh) | ||||
|     console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`) | ||||
|   } | ||||
| 
 | ||||
|   //确定远程扣分 | ||||
|   confirmKf(directives: number, code: number) { | ||||
|   confirmKf(directives: number, code: number, lsh: number) { | ||||
|     // TODO | ||||
|     // CenterUDPBusinessInstance.sendData({ | ||||
|     //   id: 37, | ||||
|     //   list: [directives, code], | ||||
|     //   carNo: this.carInfo.carNo!, | ||||
|     //   placeId: this.carInfo.examinationRoomId! | ||||
|     // }) | ||||
|     CenterUDPBusinessInstance.sendMsgExt(37, [directives, code], lsh) | ||||
|     console.info('surenjun', `考车发送确定扣分指令,指令为:${directives}`) | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -146,7 +146,39 @@ function getDataFn(config: EnvironmentConfigurationType) { | ||||
|   CenterUDPBusinessInstance.onMsg((data: CenterCallBackMsgType) => { | ||||
|     // TODO | ||||
|     // 需要观察 | ||||
|     dConsole.info(WorkerTag, "中心消息", data) | ||||
|     checkLsh() | ||||
|     dConsole.info("lixiao", data) | ||||
|     switch (Number(data.id)) { | ||||
|       case 32: | ||||
|         if (Number(data.body![0]) === 5) { | ||||
|           JudgeUdpBusinessInstance.askKf(data.body![1], udpLsh) | ||||
|         } else if (Number(data.body![0]) === 6) { | ||||
|           JudgeUdpBusinessInstance.askStopExam(data.body![1], udpLsh) | ||||
|         } else if (Number(data.body![0]) === 11) { | ||||
|           workerPort.postMessage( | ||||
|             JSON.stringify({ | ||||
|               type: WorkerBackMessageType.RemoteStartExam | ||||
|             } as WorkerBackMessage) | ||||
|           ) | ||||
|         } else if (Number(data.body![0]) === 12) { | ||||
|           dConsole.info("lixiao", 12, data) | ||||
|           workerPort.postMessage( | ||||
|             JSON.stringify({ | ||||
|               type: WorkerBackMessageType.RemoteEndExam | ||||
|             } as WorkerBackMessage) | ||||
|           ) | ||||
|         } else if (Number(data.body![0]) === 18) { | ||||
|           // TODO | ||||
|         } | ||||
|         break | ||||
|       case 36: | ||||
|         break | ||||
|       case 39: | ||||
|         break | ||||
|       default: | ||||
|         return | ||||
|     } | ||||
| 
 | ||||
|     //   收到中心指令发送出去 | ||||
|     workerPort.postMessage( | ||||
|       JSON.stringify({ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user