小红球udp
This commit is contained in:
		
							parent
							
								
									6eb48607ba
								
							
						
					
					
						commit
						d0acc157c0
					
				| @ -1,5 +1,5 @@ | ||||
| { | ||||
|   "lockfileVersion": 2, | ||||
|   "lockfileVersion": 1, | ||||
|   "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", | ||||
|   "specifiers": {}, | ||||
|   "packages": {} | ||||
|  | ||||
| @ -266,7 +266,10 @@ export const DefaultJudgeConfigData: DefaultJudgeConfigObj = { | ||||
|   //监管模式有扣分续考(0-否++1-是+把上次未考完的扣分带下来重新考试) | ||||
|   param_432: '1', | ||||
|   // Todo | ||||
|   param_634: '1' | ||||
|   // param_634: '1', | ||||
|   // Todo | ||||
|   // param_810: '1' | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| //所有的科二 科目三项目 | ||||
|  | ||||
| @ -273,8 +273,10 @@ export interface DefaultJudgeConfigObj { | ||||
|   param_369: string | ||||
|   param_375: string | ||||
|   param_387: string | ||||
|   param_392?: string | ||||
|   param_432: string | ||||
|   param_634: string | ||||
|   param_634?: string | ||||
|   param_810?: string | ||||
| } | ||||
| 
 | ||||
| export interface SyssetConfig { | ||||
|  | ||||
| @ -39,7 +39,7 @@ export interface JudgeData { | ||||
|   judgeExamEnd?: boolean | ||||
|   performInfo?: JudgePerformInfo, | ||||
|   business?: JudgeUDPData | ||||
|   remoteType?: number | ||||
|   remoteType?: 'kf' | ||||
|   remoteData?: number[] | ||||
| } | ||||
| 
 | ||||
| @ -66,7 +66,7 @@ export interface WorkerMessage { | ||||
| 
 | ||||
| export interface WorkerBackMessage { | ||||
|   type: WorkerBackMessageType; | ||||
|   data: string | CenterCallBackMsgType | ||||
|   data: string | CenterCallBackMsgType | number[] | ||||
| } | ||||
| 
 | ||||
| export enum WorkerBackMessageType { | ||||
| @ -77,7 +77,12 @@ export enum WorkerBackMessageType { | ||||
|   // 远程开始考试 | ||||
|   RemoteStartExam = 'remoteStartExam', | ||||
|   // 远程结束考试 | ||||
|   RemoteEndExam = 'remoteEndExam' | ||||
|   RemoteEndExam = 'remoteEndExam', | ||||
|   // 远程扣分 | ||||
|   RemoteKf = 'RemoteKf', | ||||
|   // 远程扣分确认 | ||||
|   RemoteKfConfirm = 'RemoteKfConfirm', | ||||
|   StopExam = 'stopExam' | ||||
| } | ||||
| 
 | ||||
| export interface LogWorkerMessage { | ||||
|  | ||||
| @ -38,7 +38,8 @@ import { | ||||
|   SYSTEM_PARAM, | ||||
|   User, | ||||
|   WorkerBackMessage, | ||||
|   WorkerBackMessageType | ||||
|   WorkerBackMessageType, | ||||
|   WorkerMessageDataType | ||||
| } from '../model'; | ||||
| import { GetSyncData } from '../utils/table/Operation'; | ||||
| import dayTs from '../utils/Date'; | ||||
| @ -114,6 +115,7 @@ export struct JudgePage { | ||||
|   @State artSubject3Projects: string[] = ['直线', '会车', '变道', '超车', '掉头', '停车'] | ||||
|   @State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4', '10', '12', '11'] | ||||
|   @State manualMarkRules: MarkRule[] = [] | ||||
|   @State markRules: MarkRule[] = [] | ||||
|   //科目三评判初始化数据 | ||||
|   @State systemparmArr: SYSTEM_PARAM[] = [] | ||||
|   @State mapPointItemArr: MAPITEMPOINTITEM[] = [] | ||||
| @ -205,7 +207,7 @@ export struct JudgePage { | ||||
|   } | ||||
| 
 | ||||
|   async aboutToAppear() { | ||||
|     DifferentialAndSignal.onMsg(this.onEndExam) | ||||
|     DifferentialAndSignal.onMsg(this.onCenterMsg) | ||||
|     this.carInfo = AppStorage.get<CarInfoType>('carInfo')! | ||||
|     this.singlePlay = AppStorage.get<boolean>('singlePlay')! | ||||
|     this.startFullTime = dayTs().format("YYYYMMDDHHmmss"); | ||||
| @ -225,7 +227,7 @@ export struct JudgePage { | ||||
|     this.signalTrajectoryDialogController.close() | ||||
|     // this.judgeBusiness.close() | ||||
|     clearInterval(this.mileageTimer) | ||||
|     DifferentialAndSignal.offMsg(this.onEndExam) | ||||
|     DifferentialAndSignal.offMsg(this.onCenterMsg) | ||||
|   } | ||||
| 
 | ||||
|   //初始化相关数据库表 | ||||
| @ -311,6 +313,7 @@ export struct JudgePage { | ||||
|       if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) { | ||||
|         this.manualMarkRules.push(tempObj) | ||||
|       } | ||||
|       this.markRules.push(tempObj) | ||||
|       tempObj.markserial = mark.markserial | ||||
|       Reflect.set(this.markRuleListObj, `${mark.itemno}_${mark.markserial}`, tempObj) | ||||
|     }) | ||||
| @ -795,11 +798,33 @@ export struct JudgePage { | ||||
|     .height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) | ||||
|   } | ||||
| 
 | ||||
|   private onEndExam = (msg: string) => { | ||||
|   private onCenterMsg = (msg: string) => { | ||||
|     let result: WorkerBackMessage = JSON.parse(msg) | ||||
|     if (result.type === WorkerBackMessageType.RemoteEndExam) { | ||||
|       dConsole.info("lixiao", msg) | ||||
|       this.judgeBusiness.JudgeEnd(true) | ||||
|     } else if (result.type === WorkerBackMessageType.RemoteKf) { | ||||
|       let data = result.data as number[] | ||||
|       const config810 = this.judgeConfigObj.param_810 | ||||
|       dConsole.info("lixiao", '评判收到远程扣分项目内容:' + `kfxh=>${data[1]}; directives=>${data[0]}`) | ||||
|       let currentKf = this.markRules.filter(item => { | ||||
|         return item.kfxh === data[1].toString() && (config810 === "1" || Number(item.markserial) > 99) | ||||
|       })[0] | ||||
|       if (!currentKf) { | ||||
|         return | ||||
|       } | ||||
|       dConsole.info("lixiao", '远程扣分项目:', currentKf) | ||||
|       this.judgeBusiness.setJudgeMark(currentKf.itemno!, currentKf.markserial!, 2) | ||||
|       DifferentialAndSignal.sendMsg({ | ||||
|         type: WorkerMessageDataType.JudgeSend, | ||||
|         data: { | ||||
|           remoteType: 'kf', | ||||
|           remoteData: [data[0]] | ||||
|         } | ||||
|       }) | ||||
|     } else if (result.type === WorkerBackMessageType.StopExam) { | ||||
|       const config392 = (this.judgeConfigObj.param_392 || '20,81').split(','); | ||||
|       this.judgeBusiness.setJudgeMark(Number(config392[0]), config392[1], 2) | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -4,6 +4,7 @@ import { | ||||
|   JudgeKSJS, | ||||
|   JudgePerformInfo, | ||||
|   LANE, | ||||
|   MarkRule, | ||||
|   PLCType, | ||||
|   ProcessDataEnumType, | ||||
|   RecordHandleType, | ||||
| @ -18,7 +19,7 @@ import { LargeJudge } from './LargeJudgeBusiness' | ||||
| import { SmallJudge } from './SmallJudgeBusiness' | ||||
| import { dConsole } from '../../utils/LogWorker' | ||||
| import { JudgeTag } from '../../config' | ||||
| import { examJudgeRealExam } from './JudgeSDKUtils' | ||||
| import { examJudgeArtificialMark, examJudgeRealExam } from './JudgeSDKUtils' | ||||
| import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' | ||||
| import { PlcStrToJson, PlcStrToWXJson } from './utils' | ||||
| import { BaseJudgeImpl, SetJudgeItem } from './BaseJudgeBussines' | ||||
| @ -119,6 +120,12 @@ export default class JudgeBusiness { | ||||
|     this.JudgeEnd() | ||||
|   } | ||||
| 
 | ||||
|   // 人工扣分 | ||||
|   public async setJudgeMark(itemno: number,markserial: string, type: number) { | ||||
|     await examJudgeArtificialMark(itemno, markserial, type) | ||||
|     //   TODO 写扣分轨迹日志 | ||||
|   } | ||||
| 
 | ||||
|   // 考试过程 callback优化 | ||||
|   public async Judging(strData: string, callBack: Function) { | ||||
|     this.judgeBusiness.Judging(strData, callBack, this.judgeUI, this) | ||||
|  | ||||
| @ -74,9 +74,6 @@ class JudgeUdpBusiness { | ||||
|     } | ||||
|     let fyj = Number(plcData.gps.fyj.toFixed(2)) | ||||
|     fyj = Math.floor(fyj > 0 ? (fyj * 100) : (fyj * 100 + 65536)) | ||||
|     let examType = this.carInfo.examSubject === "2" ? "2" : "3" | ||||
|     dConsole.info("小红球过程数据2", this.isExamEnd, this.business.kfArr) | ||||
| 
 | ||||
| 
 | ||||
|     const arr: number[][] = [ | ||||
|     //考生号 | ||||
| @ -84,7 +81,7 @@ class JudgeUdpBusiness { | ||||
|       //考试员号 | ||||
|       ascksyhArr.map(ksyh => NumberToByteArray(ksyh, 8)[0]), | ||||
|       //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 | ||||
|       NumberToByteArray(`${examType}${this.business.startTime}`, 4 * 8), | ||||
|       NumberToByteArray(`${this.carInfo.examSubject}${this.business.startTime}`, 4 * 8), | ||||
|       // 消息序号 | ||||
|       NumberToByteArray(this.isExamEnd ? 0 : this.serialIndex, 2 * 8), | ||||
|       translateSignals, | ||||
| @ -175,7 +172,6 @@ class JudgeUdpBusiness { | ||||
|     } | ||||
|     let fyj = Number(plcData.gps.fyj.toFixed(2)) | ||||
|     fyj = Math.floor(fyj > 0 ? (fyj * 100) : (fyj * 100 + 65536)) | ||||
|     let examType = this.carInfo.examSubject === "2" ? "2" : "3" | ||||
| 
 | ||||
|     const arr: number[][] = [ | ||||
|     //考生号 | ||||
| @ -183,7 +179,7 @@ class JudgeUdpBusiness { | ||||
|       //考试员号 | ||||
|       ascksyhArr.map(ksyh => NumberToByteArray(ksyh, 8)[0]), | ||||
|       //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 | ||||
|       NumberToByteArray(`${examType}${'00:00:000'}`, 4 * 8), | ||||
|       NumberToByteArray(`${0}${'00:00:000'}`, 4 * 8), | ||||
|       // 消息序号 | ||||
|       NumberToByteArray(0, 2 * 8), | ||||
|       translateSignals, | ||||
| @ -246,6 +242,15 @@ class JudgeUdpBusiness { | ||||
|     this.udp.sendMsgExt(data, udpLsh) | ||||
|   } | ||||
| 
 | ||||
|   sendMsgExt(id: number, body: number[], lsh: number) { | ||||
|     this.udp.sendMsgExt({ | ||||
|       id: id, | ||||
|       list: body, | ||||
|       carNo: this.carInfo.carNo!, | ||||
|       placeId: this.carInfo!.examinationRoomId!, | ||||
|     }, lsh) | ||||
|   } | ||||
| 
 | ||||
|   //申请远程扣分查询 | ||||
|   askKf(directives: number, lsh: number) { | ||||
|     // TODO | ||||
| @ -255,7 +260,12 @@ class JudgeUdpBusiness { | ||||
| 
 | ||||
|   askStopExam(directives: number, lsh: number) { | ||||
|     CenterUDPBusinessInstance.sendMsgExt(38, [directives], lsh) | ||||
|     console.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`) | ||||
|     dConsole.info('surenjun', `考车查询扣分项目内容,请求指令为:${directives}`) | ||||
|   } | ||||
| 
 | ||||
|   confirmStopExam(directives: number, lsh: number) { | ||||
|     CenterUDPBusinessInstance.sendMsgExt(40, [directives, 1], lsh) | ||||
|     dConsole.info('surenjun', '确定远程终止考试 directives=》' + directives) | ||||
|   } | ||||
| 
 | ||||
|   //确定远程扣分 | ||||
| @ -286,6 +296,10 @@ class JudgeUdpBusiness { | ||||
|     this.lsh = lsh || this.lsh | ||||
|   } | ||||
| 
 | ||||
|   getLsh() { | ||||
|     return this.lsh | ||||
|   } | ||||
| 
 | ||||
|   private setWholeMsg(params: UDPParamType) { | ||||
|     let head: Array<number> = this.setMsgHead(params); | ||||
|     let headJudge = this.setMessageExclusive(head); | ||||
|  | ||||
| @ -21,13 +21,15 @@ import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness'; | ||||
| import { SerialPortService } from '../utils/business/SerialPortService'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import dayTs from '../utils/Date'; | ||||
| import { NumberToByteArray } from '../utils/Common'; | ||||
| 
 | ||||
| const workerPort: ThreadWorkerGlobalScope = worker.workerPort; | ||||
| 
 | ||||
| let initDate = dayTs(new Date()).format().split(" ")[0] | ||||
| let udpLsh = 1 | ||||
| let udpIndex = 0 | ||||
| 
 | ||||
| let kfDirective: number | undefined = undefined | ||||
| let signNum: number = 0 | ||||
| 
 | ||||
| function checkLsh() { | ||||
|   let now = dayTs(new Date()).format().split(" ")[0] | ||||
| @ -62,6 +64,11 @@ workerPort.onmessage = async (e: MessageEvents) => { | ||||
|       JudgeUdpBusinessInstance.performInfo = data.performInfo ?? null | ||||
|       JudgeUdpBusinessInstance.isUDPEnd = data.judgeUdpEnd ?? false | ||||
|       JudgeUdpBusinessInstance.isExamEnd = data.judgeExamEnd ?? false | ||||
|       if (data.remoteType) { | ||||
|         if (data.remoteType === "kf") { | ||||
|           JudgeUdpBusinessInstance.confirmKf(data.remoteData![0], 1, udpLsh) | ||||
|         } | ||||
|       } | ||||
|       break | ||||
|     } | ||||
|     case WorkerMessageDataType.CenterSend: { | ||||
| @ -150,7 +157,9 @@ function getDataFn(config: EnvironmentConfigurationType) { | ||||
|     dConsole.info("lixiao", data) | ||||
|     switch (Number(data.id)) { | ||||
|       case 32: | ||||
|         signNum = data.body![1] | ||||
|         if (Number(data.body![0]) === 5) { | ||||
|           kfDirective = data.body![1] | ||||
|           JudgeUdpBusinessInstance.askKf(data.body![1], udpLsh) | ||||
|         } else if (Number(data.body![0]) === 6) { | ||||
|           JudgeUdpBusinessInstance.askStopExam(data.body![1], udpLsh) | ||||
| @ -172,9 +181,34 @@ function getDataFn(config: EnvironmentConfigurationType) { | ||||
|         } | ||||
|         break | ||||
|       case 36: | ||||
|         workerPort.postMessage( | ||||
|           JSON.stringify({ | ||||
|             type: WorkerBackMessageType.RemoteKf, | ||||
|             data: [kfDirective, data.body![0]] | ||||
|           } as WorkerBackMessage) | ||||
|         ) | ||||
|         break | ||||
|       case 39: | ||||
|       case 39: { | ||||
|         let lsh = data.body.map(byte => String.fromCharCode(byte)).join("") | ||||
|         if (lsh === JudgeUdpBusinessInstance.getLsh()) { | ||||
|           workerPort.postMessage( | ||||
|             JSON.stringify({ | ||||
|               type: WorkerBackMessageType.StopExam, | ||||
|               data: data | ||||
|             } as WorkerBackMessage)) | ||||
|           JudgeUdpBusinessInstance.confirmStopExam(signNum, udpLsh) | ||||
|         } | ||||
|         break | ||||
|       } | ||||
|       case 46: { | ||||
|         let lsh = JudgeUdpBusinessInstance.getLsh() | ||||
|         let tempList: number[] = [] | ||||
|         for (let i = 0; i < lsh.length; i++) { | ||||
|           tempList.push(NumberToByteArray(lsh.charCodeAt(i), 8)[0]) | ||||
|         } | ||||
|         JudgeUdpBusinessInstance.sendMsgExt(47, tempList, udpLsh) | ||||
|         break | ||||
|       } | ||||
|       default: | ||||
|         return | ||||
|     } | ||||
|  | ||||
| @ -1,20 +1,18 @@ | ||||
| { | ||||
|   "lockfileVersion": 2, | ||||
|   "lockfileVersion": 1, | ||||
|   "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", | ||||
|   "specifiers": { | ||||
|     "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19", | ||||
|     "@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3" | ||||
|     "@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3", | ||||
|     "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" | ||||
|   }, | ||||
|   "packages": { | ||||
|     "@ohos/hypium@1.0.19": { | ||||
|       "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", | ||||
|       "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", | ||||
|       "registryType": "ohpm" | ||||
|     }, | ||||
|     "@ohos/crypto-js@2.0.3": { | ||||
|       "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har", | ||||
|       "integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==", | ||||
|       "registryType": "ohpm" | ||||
|       "integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==" | ||||
|     }, | ||||
|     "@ohos/hypium@1.0.19": { | ||||
|       "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", | ||||
|       "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==" | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user