fix: 小红球udp结束考试

This commit is contained in:
wangzhongjie 2025-10-27 18:55:48 +08:00
parent 2ada59b81f
commit 6eb48607ba
10 changed files with 129 additions and 54 deletions

View File

@ -39,6 +39,8 @@ export interface JudgeData {
judgeExamEnd?: boolean judgeExamEnd?: boolean
performInfo?: JudgePerformInfo, performInfo?: JudgePerformInfo,
business?: JudgeUDPData business?: JudgeUDPData
remoteType?: number
remoteData?: number[]
} }
export interface CenterData { export interface CenterData {
@ -72,6 +74,10 @@ export enum WorkerBackMessageType {
ObtainUdpData = 'obtainUdpData', ObtainUdpData = 'obtainUdpData',
// 中心消息 // 中心消息
CenterUdpData = 'centerUdpData', CenterUdpData = 'centerUdpData',
// 远程开始考试
RemoteStartExam = 'remoteStartExam',
// 远程结束考试
RemoteEndExam = 'remoteEndExam'
} }
export interface LogWorkerMessage { export interface LogWorkerMessage {

View File

@ -36,7 +36,9 @@ import {
SYSSET, SYSSET,
SyssetConfig, SyssetConfig,
SYSTEM_PARAM, SYSTEM_PARAM,
User User,
WorkerBackMessage,
WorkerBackMessageType
} from '../model'; } from '../model';
import { GetSyncData } from '../utils/table/Operation'; import { GetSyncData } from '../utils/table/Operation';
import dayTs from '../utils/Date'; import dayTs from '../utils/Date';
@ -52,6 +54,7 @@ import OperatingAreaComponent from './Judge/components/OperatingArea';
import { GetIsExitManualProject } from './Judge/utils'; import { GetIsExitManualProject } from './Judge/utils';
import { InitMapPoint, InitMapPointItem } from './Judge/TableUtils'; import { InitMapPoint, InitMapPointItem } from './Judge/TableUtils';
import JudgeBusiness from './Judge/JudgeBusiness'; import JudgeBusiness from './Judge/JudgeBusiness';
import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWorker';
@Entry @Entry
@ -201,14 +204,8 @@ export struct JudgePage {
// dConsole.log("车道信号变化1", this.laneSignal) // dConsole.log("车道信号变化1", this.laneSignal)
} }
async aboutToDisappear() {
this.generateExamRecordsDialogController.close()
this.signalTrajectoryDialogController.close()
// this.judgeBusiness.close()
clearInterval(this.mileageTimer)
}
async aboutToAppear() { async aboutToAppear() {
DifferentialAndSignal.onMsg(this.onEndExam)
this.carInfo = AppStorage.get<CarInfoType>('carInfo')! this.carInfo = AppStorage.get<CarInfoType>('carInfo')!
this.singlePlay = AppStorage.get<boolean>('singlePlay')! this.singlePlay = AppStorage.get<boolean>('singlePlay')!
this.startFullTime = dayTs().format("YYYYMMDDHHmmss"); this.startFullTime = dayTs().format("YYYYMMDDHHmmss");
@ -223,6 +220,14 @@ export struct JudgePage {
await this.initJudge(); await this.initJudge();
} }
async aboutToDisappear() {
this.generateExamRecordsDialogController.close()
this.signalTrajectoryDialogController.close()
// this.judgeBusiness.close()
clearInterval(this.mileageTimer)
DifferentialAndSignal.offMsg(this.onEndExam)
}
//初始化相关数据库表 //初始化相关数据库表
async initDb() { async initDb() {
this.examSubject = this.carInfo.examSubject!; this.examSubject = this.carInfo.examSubject!;
@ -789,5 +794,13 @@ export struct JudgePage {
} }
.height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) .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)
}
}
} }

View File

@ -751,6 +751,7 @@ export class BaseJudge {
} }
async judgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { async judgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) {
dConsole.info("lixiao", 'surenjun 收到远程结束考试消息3')
const isAllProjectsEnd = judgeUI.isAllProjectsEnd const isAllProjectsEnd = judgeUI.isAllProjectsEnd
const examSubject = judgeUI.examSubject const examSubject = judgeUI.examSubject
const singlePlay = judgeUI.singlePlay const singlePlay = judgeUI.singlePlay

View File

@ -9,7 +9,7 @@ import {
RecordHandleType, RecordHandleType,
WorkerBackMessage, WorkerBackMessage,
WorkerBackMessageType, WorkerBackMessageType,
WorkerMessageDataType, WorkerMessageDataType
} from '../../model' } from '../../model'
import FileUtils from '../../utils/FileUtils' import FileUtils from '../../utils/FileUtils'
import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements' import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'
@ -115,7 +115,7 @@ export default class JudgeBusiness {
this.judgeBusiness.JudgeStart(callBack, this.judgeUI, this) this.judgeBusiness.JudgeStart(callBack, this.judgeUI, this)
// 处理PLC数据 // 处理PLC数据
// 处理实时udp里的plc信号 // 处理实时udp里的plc信号
DifferentialAndSignal.onMsg(this.onObdCallback) DifferentialAndSignal.onMsg(this.onUdpMessageCallback)
this.JudgeEnd() this.JudgeEnd()
} }
@ -126,14 +126,15 @@ export default class JudgeBusiness {
// 结束考试 // 结束考试
public JudgeEnd(isManual?: boolean) { public JudgeEnd(isManual?: boolean) {
dConsole.info("lixiao", 'surenjun 收到远程结束考试消息1')
this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual) this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
} }
close() { close() {
DifferentialAndSignal.offMsg(this.onObdCallback) DifferentialAndSignal.offMsg(this.onUdpMessageCallback)
} }
private onObdCallback = (data: string) => { private onUdpMessageCallback = (data: string) => {
const result: WorkerBackMessage = JSON.parse(data) const result: WorkerBackMessage = JSON.parse(data)
if (result.type === WorkerBackMessageType.ObtainUdpData) { if (result.type === WorkerBackMessageType.ObtainUdpData) {
this.HandlePLCData(result.data as string) this.HandlePLCData(result.data as string)

View File

@ -330,6 +330,7 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl {
} }
public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) {
dConsole.info("lixiao", 'surenjun 收到远程结束考试消息2')
super.judgeEnd(judgeUI, that, isManual) super.judgeEnd(judgeUI, that, isManual)
}; };
} }

View File

@ -43,7 +43,6 @@ import { CheckSignal, GetCurrentUserKeyValue, InitializeExamProcessData } from '
import dayTs from '../utils/Date'; import dayTs from '../utils/Date';
import { GetCurrentTime, GetPhotoBase64, NumberToByteArray } from '../utils/Common'; import { GetCurrentTime, GetPhotoBase64, NumberToByteArray } from '../utils/Common';
import DB from '../utils/DbSql'; import DB from '../utils/DbSql';
import { JudgeEmitterInstance } from '../utils/business/UdpEvent';
import { StartEndExamTag, StartExamTag, UserInfoTag } from '../config'; import { StartEndExamTag, StartExamTag, UserInfoTag } from '../config';
import { dConsole } from '../utils/LogWorker'; import { dConsole } from '../utils/LogWorker';
import HeaderComponent from './compontents/Header'; import HeaderComponent from './compontents/Header';
@ -271,6 +270,11 @@ struct UserInfoPage {
this.currentUser = this.dataList[0] this.currentUser = this.dataList[0]
this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || ""
AppStorage.setOrCreate('lsh', this.currentUser.lsh) AppStorage.setOrCreate('lsh', this.currentUser.lsh)
DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.SetExamData,
data: { lsh: this.currentUser.lsh }
})
}, 200) }, 200)
} else { } else {
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
@ -308,17 +312,13 @@ struct UserInfoPage {
// initJudgeUdp() // initJudgeUdp()
// TODO UDP更改 // 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> { async aboutToDisappear(): Promise<void> {
// CenterUDPBusinessInstance.offMsg(this.onCenterMsg) // CenterUDPBusinessInstance.offMsg(this.onCenterMsg)
// DifferentialAndSignal.offMsg(this.onCenterMsg) // DifferentialAndSignal.offMsg(this.onCenterMsg)
@ -361,6 +361,10 @@ struct UserInfoPage {
this.examinerLoginInfo.ksyh = res.ksy1sfzmhm this.examinerLoginInfo.ksyh = res.ksy1sfzmhm
AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo) AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo)
AppStorage.setOrCreate('lsh', res.lsh) AppStorage.setOrCreate('lsh', res.lsh)
DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.SetExamData,
data: { lsh: res.lsh }
})
// const { examSubject } = this.carInfo; // const { examSubject } = this.carInfo;
dConsole.log("开始考试2") dConsole.log("开始考试2")
if (this.singlePlay) { if (this.singlePlay) {
@ -388,6 +392,10 @@ struct UserInfoPage {
this.currentUser = this.list[0] this.currentUser = this.list[0]
this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || ""
AppStorage.setOrCreate('lsh', this.currentUser.lsh) AppStorage.setOrCreate('lsh', this.currentUser.lsh)
DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.SetExamData,
data: { lsh: this.currentUser.lsh }
})
}, 200) }, 200)
// promptAction.showToast({ // promptAction.showToast({
@ -463,6 +471,10 @@ struct UserInfoPage {
this.callBackFlag = false this.callBackFlag = false
AppStorage.setOrCreate('lsh', this.lsh) AppStorage.setOrCreate('lsh', this.lsh)
AppStorage.setOrCreate('statue', 2) AppStorage.setOrCreate('statue', 2)
DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.SetExamData,
data: { lsh: this.currentUser.lsh }
})
// this.currentUser = EmptyCandidateObject // this.currentUser = EmptyCandidateObject
this.numCount = 0 this.numCount = 0
if (this.singlePlay) { if (this.singlePlay) {
@ -763,6 +775,10 @@ struct UserInfoPage {
this.currentUser = user.length ? user[0] : this.dataList[0] this.currentUser = user.length ? user[0] : this.dataList[0]
this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || ""
AppStorage.setOrCreate('lsh', this.currentUser.lsh) AppStorage.setOrCreate('lsh', this.currentUser.lsh)
DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.SetExamData,
data: { lsh: this.currentUser.lsh }
})
this.examinerLoginInfo.ksyh = this.currentUser.ksy1sfzmhm this.examinerLoginInfo.ksyh = this.currentUser.ksy1sfzmhm
AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo) AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo)
}, 200) }, 200)
@ -847,22 +863,29 @@ struct UserInfoPage {
onCenterMsg = (msg: string) => { onCenterMsg = (msg: string) => {
let result = JSON.parse(msg) as WorkerBackMessage let result = JSON.parse(msg) as WorkerBackMessage
if (result.type !== WorkerBackMessageType.CenterUdpData) {
return if (result.type === WorkerBackMessageType.RemoteStartExam) {
} dConsole.log('surenjun', 'userInfo收到开始考试事件')
let val = result.data as CenterCallBackMsgType if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
dConsole.info("中心回执", val) this.prePareSCZB()
if (val.id == 32) { } else {
AppStorage.setOrCreate('signNum', val.body[1]) this.prePareExam()
if (val.body[0] == 7) { }
//缺考处理 } else if (result.type === WorkerBackMessageType.CenterUdpData) {
this.getqkFn() let val = result.data as CenterCallBackMsgType
this.signNum = val.body[1] 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() { async getExaminationItemFn() {
@ -1076,6 +1099,10 @@ struct UserInfoPage {
} }
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
AppStorage.setOrCreate('lsh', item.lsh) AppStorage.setOrCreate('lsh', item.lsh)
DifferentialAndSignal.sendMsg({
type: WorkerMessageDataType.SetExamData,
data: { lsh: item.lsh }
})
setTimeout(() => { setTimeout(() => {
this.currentUser = item this.currentUser = item
this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || "" this.currentUser.ksy2 = this.examinerLoginInfo.kgxm || ""

View File

@ -97,7 +97,7 @@ class CenterUDPBusiness {
return this.udp.close() return this.udp.close()
} }
private dealMsg(msg: ArrayBuffer): CenterCallBackMsgType { private dealMsg = (msg: ArrayBuffer): CenterCallBackMsgType => {
let arr: number[] = [] let arr: number[] = []
let dataView = new DataView(msg) let dataView = new DataView(msg)
for (let i = 0; i < dataView?.byteLength; ++i) { for (let i = 0; i < dataView?.byteLength; ++i) {

View File

@ -2,7 +2,6 @@
import worker, { MessageEvents } from '@ohos.worker'; import worker, { MessageEvents } from '@ohos.worker';
import { WorkerTag } from '../../config'; import { WorkerTag } from '../../config';
import { CarInfoType, EnvironmentConfigurationType, WorkerMessage, WorkerMessageDataType } from '../../model'; import { CarInfoType, EnvironmentConfigurationType, WorkerMessage, WorkerMessageDataType } from '../../model';
import { MsgExt } from '../UdpUtils';
class differentialAndSignal { class differentialAndSignal {
private workerInstance = new worker.ThreadWorker("entry/ets/workers/DifferentialCorrection.ets") private workerInstance = new worker.ThreadWorker("entry/ets/workers/DifferentialCorrection.ets")
@ -95,8 +94,7 @@ class differentialAndSignal {
getMessage() { getMessage() {
this.workerInstance.onmessage = (e: MessageEvents): void => { this.workerInstance.onmessage = (e: MessageEvents): void => {
if (e.data) { if (e.data) {
// console.log(WorkerTag, "Worker 收到消息: " + e.data); console.log(WorkerTag, "lixiao", "Worker 收到消息: " + e.data);
// console.log(WorkerTag, "Worker 目前监听数量: " + this.events.length.toString());
this.events.forEach((callback) => { this.events.forEach((callback) => {
callback(e.data); callback(e.data);
}); });

View File

@ -21,6 +21,7 @@ import { SerialNumberInstance } from '../SerialNumber';
import { GetCenterProjectStatus, GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils'; import { GetCenterProjectStatus, GetDwStatusType, GetTranslateSignals } from '../../pages/Judge/utils';
import { testKm2Items, testKm3Items } from '../../mock'; import { testKm2Items, testKm3Items } from '../../mock';
import { dConsole } from '../LogWorker'; import { dConsole } from '../LogWorker';
import { CenterUDPBusinessInstance } from './CenterUdpBusiness';
const Tag = "JudgeUdpBusiness" const Tag = "JudgeUdpBusiness"
@ -246,26 +247,21 @@ class JudgeUdpBusiness {
} }
//申请远程扣分查询 //申请远程扣分查询
askKf(directives: number) { askKf(directives: number, lsh: number) {
// TODO // TODO
// CenterUDPBusinessInstance.sendData({ CenterUDPBusinessInstance.sendMsgExt(35, [directives], lsh)
// id: 35, console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`)
// list: [directives], }
// carNo: this.carInfo.carNo!,
// placeId: this.carInfo.examinationRoomId!, askStopExam(directives: number, lsh: number) {
// }) CenterUDPBusinessInstance.sendMsgExt(38, [directives], lsh)
console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`) console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`)
} }
//确定远程扣分 //确定远程扣分
confirmKf(directives: number, code: number) { confirmKf(directives: number, code: number, lsh: number) {
// TODO // TODO
// CenterUDPBusinessInstance.sendData({ CenterUDPBusinessInstance.sendMsgExt(37, [directives, code], lsh)
// id: 37,
// list: [directives, code],
// carNo: this.carInfo.carNo!,
// placeId: this.carInfo.examinationRoomId!
// })
console.info('surenjun', `考车发送确定扣分指令,指令为:${directives}`) console.info('surenjun', `考车发送确定扣分指令,指令为:${directives}`)
} }

View File

@ -146,7 +146,39 @@ function getDataFn(config: EnvironmentConfigurationType) {
CenterUDPBusinessInstance.onMsg((data: CenterCallBackMsgType) => { CenterUDPBusinessInstance.onMsg((data: CenterCallBackMsgType) => {
// TODO // 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( workerPort.postMessage(
JSON.stringify({ JSON.stringify({