From 8ce99c7d8695df7f56ebefa1afb2c5056316a2d1 Mon Sep 17 00:00:00 2001 From: Surenjun Date: Fri, 28 Mar 2025 16:54:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20judge.ets=E6=96=87=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/model/Common.ets | 7 +- entry/src/main/ets/model/Judge.ets | 443 ++++-- entry/src/main/ets/pages/Judge.ets | 97 +- .../judgeSDK/api/{index.ts => index.ets} | 68 +- .../main/ets/pages/judgeSDK/api/judgeSDK.d.ts | 2 +- entry/src/main/ets/pages/judgeSDK/judge.ets | 1229 +++++++++-------- .../ets/pages/judgeSDK/utils/judgeCommon.ets | 8 +- 7 files changed, 1114 insertions(+), 740 deletions(-) rename entry/src/main/ets/pages/judgeSDK/api/{index.ts => index.ets} (66%) diff --git a/entry/src/main/ets/model/Common.ets b/entry/src/main/ets/model/Common.ets index e7670b44..c3a8825f 100644 --- a/entry/src/main/ets/model/Common.ets +++ b/entry/src/main/ets/model/Common.ets @@ -91,7 +91,7 @@ export interface BaseInfoType { } interface kfdmObj{ - xmdm:string + xmdm:number kfdm:string } // 路由参数 @@ -118,7 +118,10 @@ export interface CarInfoType { } // TODO -export interface ExaminerInfoType {} +export interface ExaminerInfoType { + code?: string + name?: string +} // 一些运行配置 export interface EnvironmentConfigurationType { diff --git a/entry/src/main/ets/model/Judge.ets b/entry/src/main/ets/model/Judge.ets index ce5a5d62..f7350686 100644 --- a/entry/src/main/ets/model/Judge.ets +++ b/entry/src/main/ets/model/Judge.ets @@ -2,7 +2,8 @@ import common from '@ohos.app.ability.common'; // ------------------------------ // 基础共用类型 // ------------------------------ -import {MA_SYSTEMPARMType} from './Table' +import { MA_SYSTEMPARMType } from './Table' + /** 基础考试字段 */ interface BaseExamFields { kchp?: string; @@ -11,13 +12,13 @@ interface BaseExamFields { kssj?: string; kskm?: string; ksxm?: string; - kscj?: string; - kslc?: string; + kscj?: number; + kslc?: number; dwlc?: string; zpsj?: string; jssj?: string; czlx?: string; - cs?: string; + cs?: number; } // ------------------------------ @@ -211,12 +212,11 @@ export interface Plc { vision: Vision, radar: Radar, extend: object - //轨迹回放需要 - method?:string - itemno:string - type:1|2 - serial:1|2 + method?: string + itemno: string + type: 1 | 2 + serial: 1 | 2 } interface Qfsj { @@ -241,16 +241,19 @@ export interface DrvexamType extends BaseExamFields { lsh?: string; zp?: string; sbxh?: string; - kffs?: string; + kffs?: number; kfsj?: string; + jssj?: string kfxm?: string; kfxmmx?: string; ghks?: string; ksxtbh?: string; ksysfzmhm?: string; Ksy2sfzmhm?: string; - ksdd:string - kslx:string + ksdd?: string + kslx?: string + zpsj?: string + dwlc?: string } @@ -343,7 +346,6 @@ export interface ProjectCenterInfos { 20400?: ProjectInfo 20600?: ProjectInfo 20700?: ProjectInfo - 40100?: ProjectInfo 40200?: ProjectInfo 40300?: ProjectInfo @@ -375,10 +377,11 @@ export interface MarkRule { nocancelid?: number NoCancelId?: number gps_sid?: number, - GPS_SID?:boolean - score?:number + GPS_SID?: boolean + score?: number xmmcStr?: string desc?: string + type?: 0|1|2 } export interface UploadExamMileage { @@ -386,40 +389,30 @@ export interface UploadExamMileage { examinationRoomId: string lsh: string kslc: number - kskssj:string + kskssj: string } export interface SYSSET { - v_no: string, - v_name: string, - v_value: string - + v_no?: string, + v_name?: string, + v_value?: string /** 轨迹文件 **/ - key?:string; - name?:string; - value?:string; + key?: number; + name?: string; + value?: string; } -/****** 评判初始化数据*****/ -export interface JudgeInitObj{ - name:string - kskm:string - systemparm:MA_SYSTEMPARMType[] - mark:MarkRule[] - sysset:SYSSET[] +export interface ProjectRoads { + param_3?: string[] + param_4?: string[] + param_10?: string[] + param_11?: string[] + param_9?: string[] + param_12?: string[] } -export interface ProjectRoads{ - param_3?:string[] - param_4?:string[] - param_10?:string[] - param_11?:string[] - param_9?:string[] - param_12?:string[] -} - -interface MAPPOINT{ +interface MAPPOINT { point_no: number, gps_e: number, gps_n: number, @@ -440,50 +433,77 @@ interface MAPITEMPOINTITEM { subname: string } -export interface JudgeUI{ +export interface JudgeUI { context: common.UIAbilityContext; - idCard:string - startFullTime:string + idCard: string + wayno: number + startFullTime: string mapPointArr: MAPPOINT[] mapPointItemArr: MAPITEMPOINTITEM[] - judgeConfigObj:object - projectsObj:ProjectInfos - - lsh:string - totalScore:number - passingScore:number - serialNumber:string - xldm:string - kslx:string - ksdd:string - - isAllProjectsEnd:boolean - examSubject:string - singlePlay:boolean - examMileage:string - jl:number - - isDeductedPopShow:boolean - defaultTabIndex:number - isDwztRight:boolean - draw:boolean - - - sd:string - dw:string + systemparmArr: SYSTEMPARMARR[] + carinfoArr: CARINFO[] + kfArr: JudgeEventKf[] + judgeConfigObj: object + judgeConfig: SyssetConfig[] + projectsObj: ProjectInfos + projects: ProjectInfo[] + projectsCenterObj: ProjectInfos + cdsbInfoObj?: CDSBInfos + itemInfoObj?: ItemInfos + markRuleListObj: object + lsh: string + carType: string + totalScore: number + passingScore: number + serialNumber: string + kssycs: string + isDdxk: boolean + ddxkTime: number + ddxkKsxmArr: string[] + ddxkKfArr: string[] + manualMarkRules: MarkRule[] + carlist: string + carName: string + xldm: string + kslx: string + ksdd: string + errorMsg: string + name: string + kfArrScroller: Scroller + disConnectErrorOpen: boolean + currentXmdm?: number + isRequiredProjectsEnd: boolean + isAllProjectsEnd: boolean + isManualProjectIn: boolean + isProjectIn: boolean + examSubject: string + singlePlay: boolean + examMileage: string + jl: number + dwztErrorVisible: boolean + isDeductedPopShow: boolean + loadingPopupVisible: boolean + endPopupVisible: boolean + defaultTabIndex: number + isDwztRight: boolean + draw: boolean + lane: JudgeLane + sd: string + dw: string } -export interface Km3JudgeInitConfig{ - map_point: MAPPOINT[] - map_point_item: MAPITEMPOINTITEM[] - iteminfo:[] - roads:string - sharps:string + +export interface ItemInfo { + model: string + xmdm: number + xmxh: string } -export interface Ksjs{ + +export interface Ksjs { // 累计前进距离 qjjl?: number, + // 累计倒车距离 dcjl?: number d1?: number @@ -494,14 +514,64 @@ export interface Ksjs{ d6?: number } -export interface CDSBInfo{ +export interface CDSBInfo { kdid?: string sbbh?: string sbbm?: string itemsno?: string modelKey?: string - xmdm?:string, - xmxh?:string + xmdm?: number, + xmxh?: string +} + +export interface SYSTEMPARMARR { + NO1: number, + NO2: number, + NO3: number, + TXT1: string, + TXT2: string, + TXT3: string, +} + +export interface CARINFO { + CARID: string, + IPADDR: string, + CARCLASS: string, + KSCX: string, + CARNAME: string, + FLAG: string, + BK1: string, + BK2: string +} + +export interface KmItem { + code: string + status: number +} + +export interface TKmItem { + code: string + status: string +} + +export interface KmItems { + '1'?: KmItem +} + +export interface JudgeConfigObj { + '1'?: string +} + +export interface MarkRules { + '1'?: MarkRule +} + +export interface CDSBInfos { + '1'?: CDSBInfo +} + +export interface ItemInfos { + '1'?: ItemInfo } // export const defaultCdsbInfoObj:DefaultJudgeConfigObj = { @@ -509,17 +579,222 @@ export interface CDSBInfo{ // } -export interface JudgeUI_I{ - context:common.UIAbilityContext +/****** 评判初始化数据*****/ +export interface JudgeInitObj extends Km3JudgeInitConfig { + sdkver: string, + appver: string + kskm: number + kchp: string + kchm: number + kscx: string + cxcode: string + name: string + carmodel: string + allitems: ItemInfo[] + iteminfo?: ItemInfo[] + systemparm: MA_SYSTEMPARMType[] + mark: MarkRule[] + sysset: SyssetConfig[] + itemInfoObj?: ItemInfos + carlist: string + carinfo: CARINFO[] + +} + +export interface JudgeKsxm { + xmdm: number + xmxh: string +} + +export interface JudgeKfxm { + xmdm: number + kfdm: string } /****** 评判开始考试数据*****/ -export interface JudgeBeginObj{ - exam:0|1 +export interface JudgeBeginObj { + kgid: string + kgxm: string + exam: 0 | 1 + replay: 0 | 1 + track: string + xm: string + sex: 0 | 1 + kslsh: string + sfzmhm: string + ksyy: string + kscx: string + kkcs: number + sfyk: number + ykkkcs: number + wayno: number + czlx: number + kskssj: number + passing: number + ksxm: JudgeKsxm[] + ddxk: 0 | 1 + ddkssj: number + ykxm: number[] + kfxm: JudgeKfxm[] + yklc: number + special?: number[] + sczb?: 0 | 1 + sczbkf?: JudgeKfxm[] + dmndg: boolean + mfxx: boolean + mfxxn: boolean } -export interface DistanceClass{ - setTimeData:(n:number)=> void +export interface JudgeXmjs { + xmdm: number + xmxh: string + xmhg: 0 | 1 +} + +export interface JudgeKf { + xmdm: number + kfdm?: string + markcatalog: string + type: 0 | 1 | 2 | 3 + xmmcStr?: string + desc?: string + score?: number + markserial?: string + kfxh?: string +} + + +export interface JudgeEventKf { + itemno?: number + markcatalog?: string + markshow?: string + markserial?: string + markstandard?: number, + markreal?: number + kfxh?: string + onlyoneid?: number + OnlyOneKind?: number + nocancelid?: number + NoCancelId?: number + gps_sid?: number, + GPS_SID?:boolean + score?:number + xmmcStr?: string + desc?: string + xmdm?: number + type?: 0 | 1 | 2 |3 +} + +export interface JudgeKsjs { + type: 0 | 1 + qjjl: number + dcjl: number + d1: number + d2: number + d3: number + d4: number + d5: number + d6: number +} + +export interface JudgeSound { + xmdm: number + code: string[] + type: 0 | 1 +} + +export interface JudgeSoundB { + xmdm: number + code: string + type: 0 | 1 +} + +export interface JudgeLane { + road: string + num: number + count: number +} + +export interface JudgeNongps { + type: 0 | 1 | 2 | 3 | 4 +} + +interface UdpKf{ + kfxh:string + directives:string +} +export interface JudgeUdpKf { + data:UdpKf +} + + +export interface JudgePerformInfo { + time: number + carzt:-1 | 0 |1 + grade:number + qjjl:number + dcjl:number + dxjl:number + bxjl:number + hint:string + lane:PerLane +} + +interface PerLane{ + MapRoad_Code_No:string + MapRoad_Name:string + TouchLineType:number + TouchDir:number + TouchLineTypeCS:number + TouchLineDirCS:number + BasePointInLaneNo:number + BaseLaneCount:number + FrontPointLaneNo:number + FrontPointLaneCount:number + Body_LF_ToLeftEdge:number + Body_LB_ToLeftEdge:number + Body_RF_ToRightEdge:number + Body_RB_ToRightEdge:number + Wheel_RF_ToRightEdge:number + Wheel_RB_ToRightEdge:number + Wheel_RF_ToBaseLine:number + Wheel_LF_ToRightEdge:number + Wheel_LB_ToRightEdge:number + Wheel_LF_ToBaseLine:number + Wheel_LB_ToBaseLine:number + BasePointInLaneDir:string + CrossLineAttr:number + InShapeAttr:number + ShapeNo:number + CrossPointNo:number +} + +export interface JudgeCallBackData { + event: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 + sj: number + carzt: -1 | 0 | 1 + xmks: JudgeKsxm + xmjs: JudgeXmjs + kf: JudgeKf + ksjs: JudgeKsjs + xmqx: JudgeKsxm + sound: JudgeSound + mndg: string + lane: JudgeLane + precast: JudgeKsxm + nongps: JudgeNongps +} + +export interface Km3JudgeInitConfig { + map_point?: MAPPOINT[] + map_point_item?: MAPITEMPOINTITEM[] + iteminfo?: ItemInfo[] + roads?: string + sharps?: string +} + +export interface DistanceClass { + setTimeData: (n: number) => void } export interface WR { diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index c03855b9..0196a31c 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -51,7 +51,11 @@ import { AmplifyItem, ProjectRoads, JudgeCallBacData, - JudgeUI + JudgeUI, + CDSBInfos, + ItemInfos, + MarkRules, + DefaultJudgeConfigObj } from '../model'; import { GetSyncData } from '../utils/table/Operation'; import dayTs from '../utils/Date'; @@ -98,13 +102,13 @@ struct Index { //模拟考试项目 @State projects: ProjectInfo[] = [] @State projectsObj: ProjectInfos = {} - @State projectsCenterObj: ProjectInfo = {} - @State markRuleListObj: MarkRule = {} - @State cdsbInfoObj?: CDSBInfo = {} - @State itemInfoObj?: object = {} + @State projectsCenterObj: ProjectInfos = {} + @State markRuleListObj: MarkRules = {} + @State cdsbInfoObj?: CDSBInfos = {} + @State itemInfoObj?: ItemInfos = {} @State timer: number = 0 @State judgeConfig: SyssetConfig[] = [] - @State judgeConfigObj: object = defaultJudgeConfigObj + @State judgeConfigObj: DefaultJudgeConfigObj = defaultJudgeConfigObj //流水号 @State lsh: string = '' @State kszp: string = '' @@ -141,7 +145,7 @@ struct Index { //项目是否进行中 @State isProjectIn: boolean = false; //正在进行的项目代码 - @State currentXmdm: string = '' + @State currentXmdm?: number = 0 // 必考项目除靠边停车是否全部完成 @State isRequiredProjectsEnd: boolean = false; @State isAllProjectsEnd: boolean = false; @@ -281,8 +285,8 @@ struct Index { if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) { this.manualMarkRules.push(tempObj) } - this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = tempObj - this.markRuleListObj[`${mark.itemno}_${mark.markserial}`].markserial = mark.markserial + tempObj.markserial = mark.markserial + Reflect.set(this.markRuleListObj, `${mark.itemno}_${mark.markserial}`, tempObj) }) } @@ -299,7 +303,7 @@ struct Index { syssetParams.forEach((sys:SYSSET) => { if (judgeConfig.isTrajectoryOpen) { - sys.v_no = sys.key; + sys.v_no = String(sys.key); sys.v_name = sys.name; sys.v_value = sys.value } @@ -342,7 +346,7 @@ struct Index { const currentProject:ProjectInfo = Reflect.get(this.projectsObj,kf.xmdm) // 过滤考前绕车一周上车准备的扣分 - if (currentParams.sczb == "1" && kf.xmdm == '1') { + if (currentParams.sczb == "1" && kf.xmdm == 1) { return } @@ -363,8 +367,7 @@ struct Index { Reflect.set(this.projectsObj,1,project_1) } - this.judgeConfigObj[sys.v_no] = value - + Reflect.set(this.judgeConfigObj, sys.v_no, value) }); this.judgeConfig = syssetJudgeConfigArr; } @@ -495,7 +498,7 @@ struct Index { const xmdm = Number( key.split('~')[0] ) const currentProject:ProjectInfo = Reflect.get(projectsObj, xmdm) if (currentProject) { - this.cdsbInfoObj[newKey] = { + const cdsbInfo:CDSBInfo = { kdid: cdsb.kdid, sbbh: cdsb.sbbh, sbbm: cdsb.sbbm, @@ -504,6 +507,7 @@ struct Index { xmdm, xmxh: key.split('~')[1], } + Reflect.set(this.cdsbInfoObj, newKey, cdsbInfo) } }) } @@ -520,19 +524,19 @@ struct Index { const xmdm = Number(key.split('~')[0]) const currentProject:ProjectInfo = Reflect.get(projectsObj,xmdm) if (currentProject && (carlistArr.length == 0 || carlistArr.includes(carlist))) { - this.itemInfoObj[newKey] = { + Reflect.set(this.itemInfoObj,newKey, { modelKey: newKey, xmdm, xmxh: key.split('~')[1], - } + }) } }) } // 评判相关初始化 async initJudge() { - const test:JudgeUI = this; - const judge = new Judge(test); + const JUDGEUI:JudgeUI = this; + const judge = new Judge(JUDGEUI); // await judge.init() await judge.onJudgeFn(async (judgeData:JudgeCallBacData) => { // const { xmmcStr, carztStr, kfArr } = judgeData; @@ -547,8 +551,9 @@ struct Index { async goDdxkItems() { const judgeConfigObj = this.judgeConfigObj + const config_432:string = Reflect.get(judgeConfigObj,'432') //科目二强制开始断点续考 - if (judgeConfigObj['432'] != 0 || this.examSubject == "2") { + if (config_432 != '0' || this.examSubject == "2") { //断点续考判断 let currentParams: RouteParamsType = router.getParams() as RouteParamsType; const examItems: string = currentParams?.examItems; @@ -559,7 +564,7 @@ struct Index { const startTime = examItemsArrs[0] const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || [] const ddxkKfArr = examItemsArrs[3]?.split('^').filter(item => item) || [] - if (judgeConfigObj['432'] == 2 || this.examSubject == "2") { + if (config_432 == '2' || this.examSubject == "2") { //TODO 带项目带里程 if (ddxkKsxmArr?.length) { //断点续考 @@ -657,7 +662,7 @@ struct Index { const beginDataObj:JudgeBeginObj = JSON.parse(beginData) const examSubject = this.carInfo.examSubject; - this.examSubject = isTrajectoryOpen ? (initDataObj.kskm) : examSubject; + this.examSubject =( isTrajectoryOpen ? (initDataObj.kskm) : examSubject) +''; this.carInfo.examSubject = this.examSubject this.singlePlay = beginDataObj.exam == 0; this.carName = initDataObj.name; @@ -739,7 +744,7 @@ struct Index { if (this.examSubject == "3") { Row() { - if (this.judgeConfigObj['375'] == '0') { + if (Reflect.get(this.judgeConfigObj,'375') == '0') { Text(`应行驶:${this.examMileage}m`) .fontColor('#E5CCA1') .fontSize(this.FONTSIZE) @@ -756,7 +761,7 @@ struct Index { Column() { Row() { Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE) - if (this.judgeConfigObj['342'] == '0') { + if (Reflect.get(this.judgeConfigObj,'342') == '0') { Text(`${this.dw}挡`).fontColor('#FFA500').fontSize(this.FONTSIZE).padding({ left: 15, right: 15 }) Text(`${this.sd}km/h`).fontColor('#FFA500').fontSize(this.FONTSIZE) } @@ -1037,7 +1042,7 @@ struct Index { // type: 1, // name: 'button_media.wav' // }) - if (this.judgeConfigObj['353'] == '0') { + if (Reflect.get(this.judgeConfigObj,'353') == '0') { this.endPopupVisible = true } else { Prompt.showToast({ @@ -1066,7 +1071,7 @@ struct Index { //科目三人工扣分弹窗 - if (this.isDeductedPopShow && this.examSubject == '3' && this.judgeConfigObj['342'] == '0') { + if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj,'342') == '0') { DeductedPopup({ defaultTabIndex: this.defaultTabIndex, currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { @@ -1150,7 +1155,7 @@ struct Index { router.back() return } - if (this.judgeConfigObj['344'] == 1) { + if (Reflect.get(this.judgeConfigObj,'344') == 1) { Prompt.showToast({ message: '考试未结束,不允许手动退出!', duration: 4000 @@ -1254,7 +1259,7 @@ struct Index { // 正在进行的项目 取消项目 if (isManualProjectIn && currentProject.type == '2') { //判断人工是否能取消项目 && 当前项目有扣分的不能取消 - if (judgeConfigObj['340'] == 1) { + if (Reflect.get(this.judgeConfigObj,'340') == 1) { await this.judge.setJudgeItem(projectCode, 2); Prompt.showToast({ message: '项目取消', @@ -1265,11 +1270,11 @@ struct Index { } // 靠边停车时候可以触发 - if (judgeConfigObj['343'] === '0') { + if (Reflect.get(this.judgeConfigObj,'343') === '0') { const xmmcStr = this.xmmcStr; if (xmmcStr == '无' || xmmcStr == '') { //512[6] 人工项目按钮放大确认 - const param512:string[] = (judgeConfigObj['512'] || '').split(','); + const param512:string[] = (Reflect.get(this.judgeConfigObj,'512') || '').split(','); console.info('surenjun', param512) if (param512[6] !== '0') { this.amplifiedImgIndex = index; @@ -1312,17 +1317,17 @@ struct Index { const projectType = currentProject.type; //不允许人工触发的项目列表,以","分隔 - const unExitManualProjects:string[] = judgeConfigObj['332'].split(',') || []; + const unExitManualProjects:string[] = Reflect.get(this.judgeConfigObj,'332').split(',') || []; //直线行驶中不进其他考试项目(0-否 1-是) - const param348:string = judgeConfigObj['348'] || '0', + const param348:string = Reflect.get(this.judgeConfigObj,'348') || '0', //里程不够允许手工点靠边停车(0-否 1-是) - param387:string = judgeConfigObj['387'] || '0', + param387:string = Reflect.get(this.judgeConfigObj,'387') || '0', //里程不够不报靠边停车(0-否+1-是+2-必考项目未完成且里程不够不报项目) - param319:string = judgeConfigObj['319'] || '0', + param319:string = Reflect.get(this.judgeConfigObj,'319') || '0', //人工项目是否能取消 1:可取消; - param340:string = judgeConfigObj['340'] || '0', + param340:string = Reflect.get(this.judgeConfigObj,'340') || '0', //307参数里设置的项目,项目已经做过,后续不能人工触发; - param307:string[] = (judgeConfigObj['307'] || '').split(','); + param307:string[] = (Reflect.get(this.judgeConfigObj,'307') || '').split(','); //非行驶状态(没有速度),人工项目不能触发(按钮灰色) if (carztStr === '停车') { @@ -1330,7 +1335,7 @@ struct Index { } //车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能) - if (judgeConfigObj['342'] === '3' || judgeConfigObj['342'] === '2') { + if (Reflect.get(this.judgeConfigObj,'342') === '3' || Reflect.get(this.judgeConfigObj,'342') === '2') { return false } @@ -1385,12 +1390,12 @@ struct Index { const num = lane.num; const count = lane.count; - const param_3:string[] = (judgeConfigObj['514']?.split(',') || []); - const param_4:string[] = (judgeConfigObj['515']?.split(',') || []); - const param_10:string[] = (judgeConfigObj['516']?.split(',') || []); - const param_11:string[] = (judgeConfigObj['517']?.split(',') || []); - const param_9:string[] = (judgeConfigObj['518']?.split(',') || []); - const param_12:string[] = (judgeConfigObj['519']?.split(',') || []); + const param_3:string[] = (Reflect.get(this.judgeConfigObj,'514')?.split(',') || []); + const param_4:string[] = (Reflect.get(this.judgeConfigObj,'515')?.split(',') || []); + const param_10:string[] = (Reflect.get(this.judgeConfigObj,'516')?.split(',') || []); + const param_11:string[] = (Reflect.get(this.judgeConfigObj,'517')?.split(',') || []); + const param_9:string[] = (Reflect.get(this.judgeConfigObj,'518')?.split(',') || []); + const param_12:string[] = (Reflect.get(this.judgeConfigObj,'519')?.split(',') || []); const projectRoads:ProjectRoads = { //直线行驶 @@ -1420,7 +1425,7 @@ struct Index { //设置了514-519参数,只能在设置的路段触发对应项目 if (currentProjectRoad.includes(road)) { //如果525为1,则514-519设置的路段不能触发对应项目 - if (judgeConfigObj['525'] == '1') { + if (Reflect.get(this.judgeConfigObj,'525') == '1') { return false } } else { @@ -1429,7 +1434,7 @@ struct Index { //405参数为2是,如果在最左侧车道,超车项目不能触发; if (projectCode == '10' && - judgeConfigObj['405'] == '2' && + Reflect.get(this.judgeConfigObj,'405') == '2' && (num === count) && num > 0 ) { @@ -1460,10 +1465,10 @@ struct Index { getIsManualKf = () => { if (this.examSubject == '3') { //杭州训练模式不允许人工评判 - if (this.singlePlay && this.judgeConfigObj['211'] == 'zjhz') { + if (this.singlePlay && Reflect.get(this.judgeConfigObj,'211') == 'zjhz') { return false } - if (this.judgeConfigObj['342'] == '0') { + if (Reflect.get(this.judgeConfigObj,'342') == '0') { return true } } else { diff --git a/entry/src/main/ets/pages/judgeSDK/api/index.ts b/entry/src/main/ets/pages/judgeSDK/api/index.ets similarity index 66% rename from entry/src/main/ets/pages/judgeSDK/api/index.ts rename to entry/src/main/ets/pages/judgeSDK/api/index.ets index 7f17688d..4642c59e 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/index.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/index.ets @@ -12,7 +12,7 @@ import libJudgeSdk from "libjudgesdk.so" * * @desc 获取版本信息 **/ -export async function examJudgeVersion() { +export async function examJudgeVersion(): Promise { return await libJudgeSdk.examJudgeVersion(); } @@ -25,7 +25,7 @@ export async function examJudgeVersion() { * @desc 设置评判日志级别和日志回调函数 */ export async function examJudgeSetLogCallback(level: number, handleLog: Function): Promise { - const temp = libJudgeSdk.examJudgeSetLogCallback(level, handleLog); + const temp:number = libJudgeSdk.examJudgeSetLogCallback(level, handleLog); return await handle(temp, 'examJudgeSetLogCallback') } @@ -35,7 +35,7 @@ export async function examJudgeSetLogCallback(level: number, handleLog: Function */ export async function examJudgeInit(data) { const str = JSON.stringify(data); - const temp = libJudgeSdk.examJudgeInit(str, str.length); + const temp:number = libJudgeSdk.examJudgeInit(str, str.length); return await handle(temp, 'examJudgeInit') } @@ -44,8 +44,7 @@ export async function examJudgeInit(data) { * @desc 执行实时考试过程 实时传递传感信息 */ export async function examJudgeRealExam(data) { - const str = JSON.stringify(data); - const temp = libJudgeSdk.examJudgeRealExam(str, str.length); + const temp:number = libJudgeSdk.examJudgeRealExam(JSON.stringify(data), str.length); return await handle(temp, 'examJudgeRealExam') } @@ -54,8 +53,8 @@ export async function examJudgeRealExam(data) { * @desc 设置评判输出的考试过程数据回调函数 */ //js_examJudgeSetRealExamCallback -export async function examJudgeSetRealExamCallback(fn) { - const temp = libJudgeSdk.examJudgeSetRealExamCallback(fn); +export async function examJudgeSetRealExamCallback(fn:Function) { + const temp:number = libJudgeSdk.examJudgeSetRealExamCallback(fn); return await handle(temp, 'examJudgeSetRealExamCallback') } @@ -63,8 +62,8 @@ export async function examJudgeSetRealExamCallback(fn) { * * @desc 设置轨迹图像回调函数 */ -export async function examJudgeMapImageSetCallback(fn) { - const temp = libJudgeSdk.examJudgeMapImageSetCallback(fn); +export async function examJudgeMapImageSetCallback(fn:Function) { + const temp:number = libJudgeSdk.examJudgeMapImageSetCallback(fn); return await handle(temp, 'examJudgeMapImageSetCallback') } @@ -81,7 +80,7 @@ export async function examJudgeArtificialMark( //扣分类型:number type: number ) { - const temp = libJudgeSdk.examJudgeArtificialMark(itemno, serial, type); + const temp:number= libJudgeSdk.examJudgeArtificialMark(itemno, serial, type); return await handle(temp, 'examJudgeArtificialMark') } @@ -95,7 +94,7 @@ export async function examJudgeArtificialItem( //操作类型 type: number = 0 ) { - const temp = libJudgeSdk.examJudgeArtificialItem(itemno, type); + const temp:number = libJudgeSdk.examJudgeArtificialItem(itemno, type); return await handle(temp, 'examJudgeArtificialMark') } @@ -104,8 +103,8 @@ export async function examJudgeArtificialItem( * * @desc 设置地图轨迹图像绘制的开关 */ -export async function examJudgeMapSetDrawing(fn) { - const temp = libJudgeSdk.examJudgeMapSetDrawing(fn); +export async function examJudgeMapSetDrawing(bool:boolean) { + const temp:number = libJudgeSdk.examJudgeMapSetDrawing(bool); return await handle(temp, 'examJudgeMapSetDrawing') } @@ -116,7 +115,7 @@ export async function examJudgeMapSetDrawing(fn) { */ export async function examJudgeBeginExam(data) { const str = JSON.stringify(data); - const temp = libJudgeSdk.examJudgeBeginExam(str, str.length); + const temp:number = libJudgeSdk.examJudgeBeginExam(str, str.length); return await handle(temp, 'examJudgeBeginExam') } @@ -124,16 +123,16 @@ export async function examJudgeBeginExam(data) { /* @params level:日志等级,infoStr:日志信息,len:数据长度 * @desc处理日志文件 */ -export function handleLog(level, infoStr, len) { - //TODO -} +// export function handleLog(level, infoStr, len) { +// //TODO +// } /* * @desc结束考试 * */ export async function examJudgeEndExam() { - const temp = libJudgeSdk.examJudgeEndExam(); + const temp:number = libJudgeSdk.examJudgeEndExam(); return await handle(temp, 'examJudgeEndExam') } @@ -142,7 +141,7 @@ export async function examJudgeEndExam() { * */ export async function examJudgeDestroy() { - const temp = libJudgeSdk.examJudgeDestroy(); + const temp:number = libJudgeSdk.examJudgeDestroy(); return await handle(temp, 'examJudgeDestroy') } @@ -151,7 +150,7 @@ export async function examJudgeDestroy() { * */ export async function examJudgeMapSetParam(width: number, height: number) { - const temp = libJudgeSdk.examJudgeMapSetParam(width, height); + const temp:number = libJudgeSdk.examJudgeMapSetParam(width, height); return await handle(temp, 'examJudgeMapSetParam') } @@ -160,7 +159,7 @@ export async function examJudgeMapSetParam(width: number, height: number) { * */ export async function examJudgeMapSetScaling(scaling?: number) { - const temp = libJudgeSdk.examJudgeMapSetScaling(scaling || 1); + const temp:number = libJudgeSdk.examJudgeMapSetScaling(scaling || 1); return await handle(temp, 'examJudgeMapSetScaling') } @@ -169,7 +168,7 @@ export async function examJudgeMapSetScaling(scaling?: number) { * */ export async function examJudgeSetPerformCallback(fn) { - const temp = libJudgeSdk.examJudgeSetPerformCallback(fn); + const temp:number = libJudgeSdk.examJudgeSetPerformCallback(fn); return await handle(temp, 'examJudgeSetPerformCallback') } @@ -178,17 +177,16 @@ export async function examJudgeSetPerformCallback(fn) { * @desc 语音播报结束 * / */ - -export async function examJudgeSoundEnd(param: { +interface SoundParam{ //项目代码 - itemno: number, + xmdm: number, //语音码 code: string, //语音类型 - type: number, -}) { - const { itemno, code, type } = param; - const temp = libJudgeSdk.examJudgeSoundEnd(itemno, code, type); + type: 0|1, +} +export async function examJudgeSoundEnd(param: SoundParam) { + const temp:number = libJudgeSdk.examJudgeSoundEnd(param.xmdm, param.code, param.type); return await handle(temp, 'examJudgeSoundEnd') } @@ -197,16 +195,16 @@ export async function examJudgeSoundEnd(param: { * @desc 实时距离计算 * * */ -export async function examCalcGpsDistance(param: { +interface DistanceParam{ jd1: number, wd1: number, jd2: number, wd2: number, h: number -}):Promise { - const { jd1, wd1, jd2, wd2, h } = param - const temp = libJudgeSdk.examCalcGpsDistance(jd1, wd1, jd2, wd2, h); - return await temp; +} +export async function examCalcGpsDistance(param:DistanceParam):Promise { + const temp:number = libJudgeSdk.examCalcGpsDistance(param.jd1, param.wd1, param.jd2, param.wd2, param.h); + return temp } @@ -214,7 +212,7 @@ export async function examCalcGpsDistance(param: { * @desc通用处理函数 * */ -async function handle(temp, fnName): Promise { +async function handle(temp:number, fnName:string): Promise { return new Promise((resolve, reject) => { if (temp == 0) { resolve(temp); diff --git a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts index 86d04926..c2763c85 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts @@ -31,7 +31,7 @@ export interface MarkRule { score?:number xmmcStr?: string desc?: string - xmdm?: string + xmdm?: number type?: 0 | 1 | 2 } diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 95ac0d94..79e385e0 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -11,6 +11,7 @@ import FileLog from './utils/fileLog'; import JudgeTask from './utils/judgeTask'; import { judgeConfig } from './utils/judgeConfig'; import { KF, LANE } from '../judgeSDK/api/judgeSDK.d'; +import { GetSyncData,SqlInsertTable } from '../../utils/table/Operation'; import { getCarStatus, @@ -42,20 +43,25 @@ import { } from './api/index'; import { writeObjectOut, uploadExamProgressData } from '../../api/judge'; -import { saveStartRecordVideo } from '../../utils/Video'; +import { saveStartRecordVideo,endRecordVideo } from '../../utils/Video'; import common from '@ohos.app.ability.common'; import { Array2Byte, convertGpsCoord2, deepClone, fillZero, string2Bytes } from './utils/Common'; import { GetCurrentTime, StringToASCII } from '../../utils/Common'; import UsbService from '../../utils/USB'; import FileUtils from '../../utils/FileUtils'; -import { BaseInfoType, CarInfoType, JudgeUI, Km3JudgeInitConfig ,ProjectInfo,Plc,DistanceClass,Ksjs,MarkRule,RegulatoryInterfaceParams,DrvexamType,WR} from '../../model'; +import { BaseInfoType, CarInfoType, JudgeUI, Km3JudgeInitConfig ,ProjectInfo,Plc,DistanceClass,Ksjs,MarkRule,RegulatoryInterfaceParams,DrvexamType,RecordHandleType,WR,CDSBInfo,ItemInfo,JudgeInitObj,RouteParamsType,ExaminerInfoType,JudgeBeginObj,JudgeKsxm,JudgeKfxm,JudgeSound,JudgeSoundB,JudgeEventKf,JudgeKsjs,JudgeXmjs,JudgeCallBackData,KmItems,KmItem, + JudgeConfigObj,User,TKmItem,JudgePerformInfo,JudgeUdpKf} from '../../model'; const judgeTag = 'SURENJUN_JUDGE' type GetKm3JudgeInitConfig = ()=> Promise +type GetgSbbm = (ksxm:number, xmxh:string) => string +type SendWriteObjectOut = (data:RegulatoryInterfaceParams, filePath:string) => Promise +type GetKfStr = (code:string) => MarkRule +type GetDqxmStr = (xmdm:number) => string - +type TJudgeBeginObj = JudgeBeginObj export default class Judge { // 断网数据补传 uploadDisConnectData = async () => { @@ -80,8 +86,8 @@ export default class Judge { const folderPath = fileLog.folderPath const base64 = new util.Base64(); - const time = GetCurrentTime(); - const endTime = GetCurrentTime(1) + const time = await GetCurrentTime(); + const endTime = await GetCurrentTime(1) let examDataBase64: string = '' //TODO try catch报错待优化 const examDataStr: string = await this.fileUtil.readFile(`${folderPath}/wuxi_progress_data.txt`); @@ -139,7 +145,7 @@ export default class Judge { private context: common.UIAbilityContext public judgeUI: JudgeUI // 检测扣分、结束项目时该项目是否开始 - checkProjectIsStart = async (xmdm:number, currentType: 1 | 2, kf?: KF) => { + checkProjectIsStart = async (xmdm:number, currentType: 1 | 2, kf?: JudgeEventKf) => { if (xmdm == 20) { return true } @@ -237,8 +243,8 @@ export default class Judge { } private xmmcStr: string private xmmcCode: string - private xmmcSingleCode: number - private xmmcEndCode?: number + private xmmcSingleCode: string + private xmmcEndCode?: string private xmdm: string | number private xmxh: string private fileModel: FileModel @@ -289,7 +295,7 @@ export default class Judge { this.prevJd = tJD; this.prevWd = tWD; } - private performInfo: any + private performInfo?: JudgePerformInfo private isEndTip: boolean = false; private deductedPopShowTimer: number = 0; // 校验考试是否结束 @@ -405,10 +411,10 @@ export default class Judge { } } } - private ksjs: Ksjs - private kfArr: MarkRule[] + private ksjs: JudgeKsjs + private kfArr: JudgeEventKf[] //所有的科目考试项目(大车&小车) - private testKmItems: any + private kmItems: KmItems private plcData: Plc // 获取plc数据 getPlcData = async (plc: string) => { @@ -499,7 +505,7 @@ export default class Judge { // globalThis.judgeTimer = judgeTimer; } //当前科目二的考试项目 - private currentKm2ItemsObj: any + // private currentKm2ItemsObj: any //本地轨迹回放地址 private trajectoryPath: string private isTrajectoryOpen: boolean; @@ -509,7 +515,7 @@ export default class Judge { beginProject = async (ksxm:number) => { const carInfo = AppStorage.get('carInfo'); const judgeUI = this.judgeUI - const time = GetCurrentTime(); + const time = await GetCurrentTime(); const project:ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) const sbxh = this.getSbbm(ksxm, this.xmxh) @@ -542,48 +548,47 @@ export default class Judge { // 项目结束接口同步 endProject = async (ksxm:number) => { const carInfo = AppStorage.get('carInfo'); - const { examSubject, plateNo, carNo } = carInfo; - const { judgeUI, fileLog, getSbxh, xmxh, getSbbm, filePath } = this; - const { lsh, idCard, serialNumber, projectsObj, cdsbInfoObj, ksdd, kslx, xldm, } = judgeUI + const judgeUI = this.judgeUI; const time = await GetCurrentTime(); - const project = projectsObj[ksxm] - const sbxh = examSubject == 3 ? undefined : getSbbm(ksxm, xmxh) + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,ksxm) + const sbxh = judgeUI.examSubject == '3' ? undefined : this.getSbbm(ksxm, this.xmxh) - const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C55', - drvexam: { - lsh, - kskm: examSubject, - sfzmhm: idCard, - ksxm: project.projectCodeCenter, - sbxh, - //TODO 操作类型 1:正常 0:撤销该考试记录 - czlx: '1', - ksxl: xldm, - kchp: encodeURI(plateNo), - ksdd: encodeURI(ksdd), - kslx: encodeURI(kslx) || '', - jssj: time - } + const drvexam:DrvexamType = { + lsh:judgeUI.lsh, + kskm: carInfo.examSubject, + sfzmhm: judgeUI.idCard, + ksxm: project.projectCodeCenter, + sbxh, + //TODO 操作类型 1:正常 0:撤销该考试记录 + czlx: '1', + ksxl: judgeUI.xldm, + kchp: encodeURI(carInfo.plateNo), + ksdd: encodeURI(judgeUI.ksdd), + kslx: encodeURI(judgeUI.kslx) || '', + jssj: time } - const { code } = await this.sendWriteObjectOut(data, filePath) - if (code === 2300007) { + const data:RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: judgeUI.serialNumber, + jkid: '17C55', + drvexam + } + const temp:WR = await this.sendWriteObjectOut(data, this.filePath) + if (temp.code === 2300007) { this.isJudgeDisConnect = true; } console.info(judgeTag, '项目结束 end') - promptWxCode('17C55', code) + promptWxCode('17C55', temp.code) } private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] private lane: LANE = { road: '', num: 0, count: 0 } - private videoData: any + private videoData: RecordHandleType private disConnectNum: number = 0; //调用监管接口 - sendWriteObjectOut = async (data:RegulatoryInterfaceParams, filePath:string) => { + sendWriteObjectOut:SendWriteObjectOut = async (data, filePath) => { const temp = await writeObjectOut(data, filePath); console.log("wzj", JSON.stringify(temp)) //断网&网络超时次数计算 @@ -604,37 +609,37 @@ export default class Judge { return temp } // 考试过程照片 - uploadProgressPhoto = async (ksxm) => { + uploadProgressPhoto = async (ksxm:number) => { const time = await GetCurrentTime(); - const { judgeUI, plcData, getPhoto, fileLog, filePath } = this; - const photoBase64 = await getPhoto(); + const judgeUI = this.judgeUI + const plcData = this.plcData + const photoBase64 = await this.getPhoto(); const carInfo = AppStorage.get('carInfo'); - const { examSubject, plateNo, carNo } = carInfo; - const { lsh, idCard, serialNumber, projectsObj, ksdd, judgeConfigObj } = judgeUI; - const { sensor, gps } = plcData - const project = projectsObj[ksxm] - const data = { + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const judgeConfig_305:number = Reflect.get(judgeUI.judgeConfigObj, '305') + const drvexam:DrvexamType = { + lsh:judgeUI.lsh, + kskm: carInfo.examSubject, + ksxm: project.projectCodeCenter, + sfzmhm: judgeUI.idCard, + kchp: encodeURI(carInfo.plateNo), + zpsj: time, + zp: photoBase64, + cs: Math.floor((judgeConfig_305 == 0 ? plcData.gps.sd : plcData.sensor.cs) * 1.852), + ksdd: encodeURI(judgeUI.ksdd) + } + const data:RegulatoryInterfaceParams = { xtlb: '17', - jkxlh: serialNumber, + jkxlh: judgeUI.serialNumber, jkid: '17C54', - drvexam: { - lsh, - kskm: examSubject, - ksxm: project.projectCodeCenter, - sfzmhm: idCard, - kchp: encodeURI(plateNo), - zpsj: time, - zp: photoBase64, - cs: Math.floor((judgeConfigObj['350'] == 0 ? gps.sd : sensor.cs) * 1.852), - ksdd: encodeURI(ksdd) - } + drvexam }; - const { code } = await this.sendWriteObjectOut(data, filePath); - if (code === 2300007) { + const temp:WR = await this.sendWriteObjectOut(data, this.filePath); + if (temp.code === 2300007) { this.isJudgeDisConnect = true } - promptWxCode('17C54', code) + promptWxCode('17C54', temp.code) console.info(judgeTag, '上传照片 end') } @@ -655,29 +660,23 @@ export default class Judge { this.xmmcCode = ''; this.xmmcEndCode = undefined; this.carztStr = ''; - this.testKmItems = {}; + this.kmItems = {}; // 考试回放配置 - const { isTrajectoryOpen, modelPath, trajectoryPath } = judgeConfig - this.isTrajectoryOpen = isTrajectoryOpen; - this.modelPath = modelPath; - this.trajectoryPath = trajectoryPath; + this.isTrajectoryOpen = judgeConfig.isTrajectoryOpen; + this.modelPath = judgeConfig.modelPath; + this.trajectoryPath = judgeConfig.trajectoryPath; this.isExam = !this.judgeUI.singlePlay; - const { projectsCenterObj, examSubject } = judgeUI; + (judgeUI.examSubject == '2' ? testKm2Items : testKm3Items).forEach(item => { + const projectCenterObj:ProjectInfo = Reflect.get(judgeUI.projectsCenterObj,item.code) - (examSubject == 2 ? testKm2Items : testKm3Items).forEach(item => { - const projectCenterObj = projectsCenterObj[item.code] - this.testKmItems[item.code] = item; - //考试项目存在 - this.testKmItems[item.code] = { - code: item.code, - status: projectCenterObj === undefined - ? 0 - : (projectCenterObj.isEnd ? 3 : 1) - } + const currentItem:KmItem = Reflect.get(this.kmItems,item.code) + currentItem.code = item.code + currentItem.status = projectCenterObj === undefined ? 0 : (projectCenterObj.isEnd ? 3 : 1) + Reflect.set(this.kmItems,item.code,currentItem) }) - console.info(judgeTag + 'testKmItems', JSON.stringify(this.testKmItems)) + console.info(judgeTag + 'testKmItems', JSON.stringify(this.kmItems)) this.isExamEnd = false; } @@ -687,67 +686,103 @@ export default class Judge { // 获取评判初始化数据 getJudgeInitData = async () => { - const { getModelData, getKm3JudgeInitConfig } = this const carInfo = AppStorage.get('carInfo'); - const { examSubject, plateNo, carId } = carInfo; const judgeUI = this.judgeUI - const { projectsObj, itemInfoObj, markRuleListObj, carType, carName, systemparmArr, carinfoArr } = judgeUI - const examType = examSubject == 2 ? 'km2' : 'km3' + const projectsObj = judgeUI.projectsObj + const itemInfoObj = judgeUI.itemInfoObj + const markRuleListObj = judgeUI.markRuleListObj + const carType = judgeUI.carType + const carName = judgeUI.carName + const systemparmArr = judgeUI.systemparmArr + const carinfoArr = judgeUI.carinfoArr + const examType = carInfo. examSubject == '2' ? 'km2' : 'km3' - let allitems = []; - if (examSubject == 2) { + let allitems:ItemInfo[] = []; + if (judgeUI.examSubject == '2') { allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { - const cdsb = itemInfoObj[cdsbKey]; - const { xmdm, xmxh, modelKey } = cdsb - return { - xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`) - } + const cdsb:CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); + const model = this.getModelData(`${examType}/${cdsb.modelKey}.txt`) + const temp:ItemInfo = {xmdm:cdsb.xmdm,xmxh:cdsb.xmxh,model} + return temp }) } + //获取版本号 - const sdkver = await examJudgeVersion(); - const initInfo = { - sdkver, + const mark:MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => { + const current:MarkRule = Reflect.get(markRuleListObj,ruleKey) + return current + }) + const initInfo:JudgeInitObj = { + sdkver:await examJudgeVersion(), appver: AppStorage.get('baseInfo').version, - kskm: examSubject * 1, - kchp: plateNo, - kchm: carId * 1, + kskm: Number(carInfo.examSubject), + kchp: carInfo.plateNo, + kchm: Number(carInfo.carId), kscx: carType, cxcode: '1', name: carName, - carmodel: getModelData(`${examType}/${carType}.txt`), + carmodel: this.getModelData(`${examType}/${carType}.txt`), allitems, iteminfo: [], systemparm: systemparmArr, - mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules, + mark, sysset: judgeUI.judgeConfig, itemInfoObj, carlist: judgeUI.carlist, carinfo: carinfoArr, }; - let km3Config = {} + let km3Config:Km3JudgeInitConfig = {} - if (examSubject == 3) { - km3Config = await getKm3JudgeInitConfig(); + if (judgeUI.examSubject == '3') { + km3Config = await this.getKm3JudgeInitConfig(); + initInfo.map_point = km3Config.map_point + initInfo.map_point_item = km3Config.map_point_item + initInfo.iteminfo = km3Config.iteminfo + initInfo.roads = km3Config.roads + initInfo.sharps = km3Config.sharps } // 获取科目三的评判配置 console.info(judgeTag, '3.获取评判初始化数据完成') - return { - ...initInfo, - ...km3Config, - } + return initInfo + } // 获取开始考试数据 getJudgeBeginData = async () => { - const examinerInfo = AppStorage.get('examinerInfo') - const { code, name:examinerName } = examinerInfo; - let currentParams: any = router.getParams(); - const { sczb, kfdm } = currentParams; - const { isExam } = this; + const examinerInfo = AppStorage.get('examinerInfo') + const code = examinerInfo.code + const examinerName = examinerInfo.name + + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + const sczb = currentParams.sczb; + const kfdm = currentParams.kfdm; + const isExam = this.isExam; const judgeUI = this.judgeUI - const { projects, carType, kssycs, isDdxk, ddxkTime, projectsCenterObj, ddxkKsxmArr, ddxkKfArr, passingScore } = - judgeUI; - const beginInfo = { + + const projects = judgeUI.projects + const carType = judgeUI.carType + const kssycs = judgeUI.kssycs + const isDdxk = judgeUI.isDdxk + const ddxkTime = judgeUI.ddxkTime + const projectsCenterObj = judgeUI.projectsCenterObj + const ddxkKsxmArr = judgeUI.ddxkKsxmArr + const ddxkKfArr = judgeUI.ddxkKfArr + const passingScore = judgeUI.passingScore + + const ksxm:JudgeKsxm[] = projects.map(project => { + const temp:JudgeKsxm = {xmdm: Number(project.projectCode), xmxh: ''} + return temp + }) + + const ykxm:number[] = (ddxkKsxmArr?.map(projectCenterCode => { + const currentProject:ProjectInfo =Reflect.get(projectsCenterObj, projectCenterCode) + return Number(currentProject.projectCode) + })) || []; + + const kfxm:JudgeKfxm[] = isDdxk ? (ddxkKfArr?.map(kf => { + return { xmdm:Number(kf.split(',')[0]), kfdm:kf.split(',')[1]} as JudgeKfxm + })) : [] + + const beginInfo:JudgeBeginObj = { kgid: '012', kgxm: decodeURI(examinerName || ''), exam: isExam ? 1 : 0, @@ -764,31 +799,20 @@ export default class Judge { kkcs: Number(kssycs) || 2, sfyk: 0, ykkkcs: 1, - wayno: judgeUI.wayno * 1, + wayno: Number(judgeUI.wayno), czlx: 0, - kskssj: await systemTime.getCurrentTime(), - passing: passingScore * 1, - ksxm: projects.map(project => { - return { - xmdm: project.projectCode * 1, - xmxh: '', - } - }), + kskssj:await systemTime.getCurrentTime(), + passing: Number(passingScore), + ksxm, //断点续考 ddxk: isDdxk ? 1 : 0, ddkssj: ddxkTime || 0, - ykxm: (ddxkKsxmArr?.map(projectCenterCode => (projectsCenterObj[projectCenterCode]?.projectCode) * 1)) || [], - kfxm: isDdxk ? (ddxkKfArr?.map(kf => { - const [xmdm, kfdm] = kf.split(',') - return { - xmdm: xmdm * 1, kfdm - } - })) : [], + ykxm, + kfxm, //TODO 已考里程待修改 yklc: 0, special: [], - //TODO 科目三参数临时写死 - sczb: (sczb === undefined || sczb == 0) ? 0 : 1, + sczb: (sczb === undefined || sczb == '0') ? 0 : 1, sczbkf: kfdm, dmndg: false, mfxx: false, @@ -798,33 +822,56 @@ export default class Judge { return beginInfo } //处理评判过程回调 - handleRealExam = async (strData, callBack) => { - let examData: EXAMDATA = JSON.parse(strData); - const { getDqxmStr, getKfStr, goJudgeVoice, setMndg, avPlayer, fileLog, judgeUI } = this; - const { carzt, xmks, kf, event, xmjs, xmqx, ksjs, sound, mndg, lane, precast, nongps } = examData - const param512 = (judgeUI.judgeConfigObj['512'] || '').split(','); + handleRealExam = async (strData:string, callBack:Function) => { + let examData: JudgeCallBackData = JSON.parse(strData); + + const getDqxmStr = this.getDqxmStr; + const getKfStr = this.getKfStr; + const goJudgeVoice = this.goJudgeVoice; + const setMndg = this.setMndg; + const avPlayer = this.avPlayer; + const fileLog = this.fileLog; + const judgeUI = this.judgeUI; + + const carzt = examData.carzt + const xmks = examData.xmks + const kf = examData.kf + const event = examData.event + const xmjs = examData.xmjs + const xmqx = examData.xmqx + const ksjs = examData.ksjs + const sound = examData.sound + const mndg = examData.mndg + const lane = examData.lane + const precast = examData.precast + const nongps = examData.nongps //获取项目结束、项目开始代码 const xmdm = event == 2 ? xmjs.xmdm : xmks.xmdm const xmxh = event == 2 ? xmjs.xmxh : xmks.xmxh; const isManualProjectIn = this.artSubject3ProjectsCodesArr.includes(xmdm); - const { examSubject, projects, judgeConfigObj } = this.judgeUI; - const param611 = judgeConfigObj['611'] || ''; + const examSubject = this.judgeUI.examSubject + const projects = this.judgeUI.projects + const judgeConfigObj = this.judgeUI.judgeConfigObj + + switch (event) { //项目开始 case 1: - judgeUI.projectsObj[xmdm].type = '2'; + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + project.type = '2'; if (isManualProjectIn) { //手动项目是否在进行中 this.judgeUI.isManualProjectIn = true } - if (xmdm == 41 && examSubject == 3) { + if (xmdm == 41 && examSubject == '3') { this.rmndg = 1 } this.judgeUI.currentXmdm = xmdm; - const xmmcStr = judgeUI.projectsObj[xmdm].name; - const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; - this.testKmItems[xmmcCode].status = 2; + const xmmcStr = project.name; + const xmmcCode = project.projectCodeCenter; + const xmmcSingleCode = project.projectCode; + const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + kmItem.status = 2; this.xmmcStr = xmmcStr; this.xmmcCode = xmmcCode; this.xmmcSingleCode = xmmcSingleCode @@ -832,35 +879,43 @@ export default class Judge { this.xmdm = xmdm; this.xmxh = xmxh; this.judgeUI.isProjectIn = true + Reflect.set(this.judgeUI.projectsObj,xmdm,project) + Reflect.set(this.kmItems,xmmcCode,kmItem) break; //项目结束 case 2: { - const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - judgeUI.projectsObj[xmdm].type = (xmjs.xmhg === 0 ? '4' : '3'); + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + const xmmcCode = project.projectCodeCenter; + project.type = (xmjs.xmhg === 0 ? '4' : '3') + //计算项目是否全部结束 - this.judgeUI.isProjectIn = (Reflect.ownKeys(judgeUI.projectsObj).filter( - projectKey => judgeUI.projectsObj[projectKey].type == '2').length - ) > 0; + this.judgeUI.isProjectIn = (Reflect.ownKeys(judgeUI.projectsObj).filter((projectKey)=>{ + const fillProject:ProjectInfo = Reflect.get( judgeUI.projectsObj,projectKey) + return fillProject.type == '2' + }).length) > 0; + if (isManualProjectIn) { this.judgeUI.isManualProjectIn = false } - this.testKmItems[xmmcCode].status = 3; + const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + kmItem.status = 3; //统计必考项目数量 this.xmmcStr = '无'; this.xmmcCode = ''; this.xmdm = ''; this.judgeUI.currentXmdm = undefined; + Reflect.set(this.judgeUI.projectsObj,xmdm,project) + Reflect.set(this.kmItems,xmmcCode,kmItem) break; } //扣分 case 3: - const thisKf = getKfStr(`${kf.xmdm}_${kf.kfdm}`) - //扣分信息 - this.kfArr.push({ + const thisKf = this.getKfStr(`${kf.xmdm}_${kf.kfdm}`) + const kfObj:JudgeEventKf = { //扣分项目名称 - xmmcStr: getDqxmStr(kf.xmdm), + xmmcStr: this.getDqxmStr(kf.xmdm), xmdm: kf.xmdm, //扣分描述 desc: thisKf.desc, @@ -872,11 +927,15 @@ export default class Judge { kfxh: thisKf.kfxh, //扣分类型 type: kf.type - }) + } + //扣分信息 + this.kfArr.push(kfObj) this.judgeUI.totalScore += thisKf.score * 1; if (kf.xmdm != 20) { - const type = judgeUI.projectsObj[kf.xmdm].type; - judgeUI.projectsObj[kf.xmdm].type = (type == 3 || type == 4) ? '4' : '5'; + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,kf.xmdm) + const type = project.type; + project.type = (type == '3' || type == '4') ? '4' : '5' + Reflect.set(this.judgeUI.projectsObj,kf.xmdm,project) } break; @@ -888,32 +947,34 @@ export default class Judge { //考试结束 case 5: this.ksjs = ksjs; - await fileLog.setExamJudgeData({ - method: 'examJudgeEndExam', - }) + await fileLog.setExamJudgeData(JSON.stringify({method: 'examJudgeEndExam'})) break; //项目取消 case 6: { console.info(judgeTag, '项目取消'); - const { examSubject } = this.judgeUI const xmdm = xmqx.xmdm; - const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + // const examSubject = this.judgeUI.examSubject + const xmmcCode = project.projectCodeCenter; + // const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); // avPlayer.playAudio([`voice/${voiceCode}.mp3`],true) - this.judgeUI.projectsObj[xmdm].type = '1'; - this.testKmItems[xmmcCode].status = '1'; + project.type = '1' + const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + Reflect.set(this.judgeUI.projectsObj,xmdm,project) + kmItem.status = 1 + Reflect.set(this.kmItems,xmmcCode,kmItem) break; } //语音播放和提示 case 7: - goJudgeVoice(sound) + this.goJudgeVoice(sound) break; //模拟灯光事件 case 8: - setMndg(mndg) + this.setMndg(mndg) break; //车道和路段变化 @@ -924,39 +985,36 @@ export default class Judge { //预进项目事件 case 10: { - const param611 = judgeConfigObj['611'] || ''; - const [f, s] = param611.split('/') - const { xmdm, xmxh } = precast; - const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; - const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; - // if(examSubject == 2 && ((xmdm == 0 && f == 1) || (xmdm == 1 && s == 1) || xmdm == 3)){ - // //倒车入库/桩考/侧方停车 - // avPlayer.playAudio([`voice/${xmmcCode}.mp3`],false) - // } - this.testKmItems[xmmcCode].status = 2; + const param611:JudgeConfigObj = Reflect.get(judgeConfigObj,'611') || '' + const xmdm = precast.xmdm + const xmxh = precast.xmxh + const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + const xmmcCode = project.projectCodeCenter + const projectCode = project.projectCode + // const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; + // const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; + const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + kmItem.status = 2; + Reflect.set(this.kmItems,xmmcCode,project) this.xmmcStr = xmmcStr; this.xmmcCode = xmmcCode; this.xmdm = xmdm; this.xmxh = xmxh; this.xmmcSingleCode = xmmcSingleCode; - judgeUI.projectsObj[xmdm].type = '2'; + project.type = '2'; + Reflect.set(this.judgeUI.projectsObj,xmdm,project) } break; - //差分事件 case 11: { this.checkDwzt(nongps.type) } default: break; - } - - const { xmmcStr, carztStr, kfArr } = this; - await callBack({ //项目名称 考车状态 扣分arr - xmmcStr, carztStr, kfArr + xmmcStr:this.xmmcStr, carztStr:this.carztStr, kfArrt:this.kfArr }); //语音播报 @@ -968,35 +1026,40 @@ export default class Judge { } } // 更改考试状态 - goVoiceAnnounce = async (event, xmdm, kf, xmjs, ksjs, xmxh) => { - const { - beginProject, - pointsDedute, - endProject, - avPlayer, - uploadProgressPhoto, - judgeTask, - handEndExam, - judgeUI, - checkExamIsEnd, - checkProjectIsStart, - lane, - closeAllFiles - } = this; + goVoiceAnnounce = async (event:number, xmdm:number, kf:JudgeEventKf[], xmjs:JudgeXmjs, ksjs:JudgeKsjs, xmxh:string) => { + + const beginProject = this.beginProject + const pointsDedute = this.pointsDedute + const endProject = this.endProject + const avPlayer = this.avPlayer + const uploadProgressPhoto = this.uploadProgressPhoto + const judgeTask = this.judgeTask + const handEndExam = this.handEndExam + const judgeUI = this.judgeUI + const checkExamIsEnd = this.checkExamIsEnd + const checkProjectIsStart = this.checkProjectIsStart + const lane = this.lane + const closeAllFiles = this.closeAllFiles + + const projectsObj = judgeUI.projectsObj + const judgeConfigObj = judgeUI.judgeConfigObj + const examSubject = judgeUI.examSubject + const jl = judgeUI.jl + const isAllProjectsEnd = judgeUI.isAllProjectsEnd - const { projectsObj, judgeConfigObj, examSubject, examMileage, jl, isAllProjectsEnd } = judgeUI; const kfLen = kf.length; //不报语音的项目列表 - const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') - const param611 = judgeConfigObj['611'] || ''; - const param512 = (judgeConfigObj['512'] || '').split(','); - const [f, s] = param611.split('/') + // const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') + // const param611 = judgeConfigObj['611'] || ''; + // const [f, s] = param611.split('/') switch (event) { // 项目开始 case 1: - const code = projectsObj[xmdm].projectCodeCenter; - const isEnd = projectsObj[xmdm].isEnd; - const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) + const param512:JudgeConfigObj = (Reflect.get(judgeConfigObj,'512') || '').split(','); + const project:ProjectInfo = Reflect.get(projectsObj,xmdm) + const code = project.projectCodeCenter; + const isEnd = project.isEnd; + // const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) // if (!ignoreVoiceCodeArr.includes(code)) { // if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){ // //倒出入库、桩考\进项目语音控制 @@ -1005,7 +1068,7 @@ export default class Judge { // } // } setTimeout(() => { - if (param512[7] != 0) { + if (Reflect.get(param512,7) != 0) { clearTimeout(this.deductedPopShowTimer) this.judgeUI.isDeductedPopShow = true } @@ -1013,38 +1076,36 @@ export default class Judge { //项目已考不上传监管信息 if (!isEnd) { judgeTask.addTask(async () => { - console.info(judgeTag, `项目开始-${xmdm}-${projectsObj[xmdm].name}`) + console.info(judgeTag, `项目开始-${xmdm}-${project.name}`) await beginProject(xmdm) - }, { - isDelay: true - }) + }, {isDelay: true}) judgeTask.addTask(async () => { console.info(judgeTag, `项目-${xmdm}-上传照片 start`) await uploadProgressPhoto(xmdm) - }, { - isDelay: true - }) - this.judgeUI.projectsObj[xmdm].isUpload = true; + }, {isDelay: true}) + project.isUpload = true; + Reflect.set(this.judgeUI.projects,xmdm,project) } break; // 项目结束 case 2: { - const endCode = projectsObj[xmdm].projectCodeCenter; - const projectIsEnd = projectsObj[xmdm].isEnd; - const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh) + const project:ProjectInfo = Reflect.get(projectsObj,xmdm) + const endCode = project.projectCodeCenter; + const projectIsEnd = project.isEnd; + // const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh) // if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { // endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) // } - const isStart = await checkProjectIsStart(xmdm, 1); + const isStart = await this.checkProjectIsStart(xmdm, 1); if (isStart) { //项目结束了就不再生成数据 console.info(judgeTag + ' projectIsEnd =>', projectIsEnd) if (!projectIsEnd) { judgeTask.addTask(async () => { - console.info(judgeTag, `项目结束-${xmdm}-${projectsObj[xmdm].name}`) + console.info(judgeTag, `项目结束-${xmdm}-${project.name}`) await endProject(xmdm); - this.xmmcSingleCode = 0; + this.xmmcSingleCode = '0'; this.xmmcEndCode = undefined; }, { isDelay: true @@ -1054,9 +1115,10 @@ export default class Judge { if (!this.judgeUI.isProjectIn) { this.deductedPopShowTimer = setTimeout(() => { this.judgeUI.isDeductedPopShow = false - }, (param512[5] || 0) * 1000) + }, (Reflect.get(param512,5) || 0) * 1000) } - judgeUI.projectsObj[xmdm].isEnd = true; + project.isEnd = true; + Reflect.set(this.judgeUI.projects,xmdm,project) break; } @@ -1065,8 +1127,8 @@ export default class Judge { console.info('surenjun', '扣分开始') //扣分时实时播报语音(0-否+1-是) const currentKf = kf[kfLen -1]; - if (judgeConfig.kfVoiceOpen || (examSubject == 2 && judgeConfigObj['618'] == '1') || - (examSubject == 3 && judgeConfigObj['418'] == '1')) { + if (judgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '1') || + (examSubject == '3' && judgeConfigObj['418'] == '1')) { avPlayer.playAudio([`voice/${currentKf.markcatalog}.mp3`, `voice/mark_${Math.abs(currentKf.score)}.mp3`]) } const isStart = await checkProjectIsStart(currentKf.xmdm, 2, currentKf); @@ -1097,7 +1159,8 @@ export default class Judge { AppStorage.setOrCreate('isJudge', false) await handEndExam(ksjs) }) - clearInterval(globalThis.judgeTimer) + // TODO待修改 + // clearInterval(globalThis.judgeTimer) break default: break @@ -1114,17 +1177,34 @@ export default class Judge { } } // 考试扣分 - pointsDedute = async (ksxm, kf) => { + pointsDedute = async (ksxm:number, kf:JudgeEventKf) => { const carInfo = AppStorage.get('carInfo'); - const { examSubject, plateNo, carNo } = carInfo; - const { judgeUI, getProjectInfo, fileLog, xmmcSingleCode, xmmcEndCode, filePath } = this; - const { lsh, idCard, serialNumber, ksdd, projectsObj } = judgeUI + const examSubject = carInfo.examSubject + const plateNo = carInfo.plateNo + const carNo = carInfo.carNo + + const judgeUI = this.judgeUI + const getProjectInfo = this.getProjectInfo + const fileLog = this.fileLog + const xmmcSingleCode = this.xmmcSingleCode + const xmmcEndCode = this.xmmcEndCode + const filePath = this.filePath + + const lsh = judgeUI.lsh + const idCard = judgeUI.idCard + const serialNumber = judgeUI.serialNumber + const ksdd = judgeUI.ksdd + const projectsObj = judgeUI.projectsObj + const time = await GetCurrentTime(); - const project = getProjectInfo(ksxm); + const project = this.getProjectInfo(ksxm); //科目三夜间行驶.模拟灯光、上车准备出现通用评判,ksxm为当前进行的项目 const checkProjects = ['17', '41', '1']; //获取正在进行的项目 - const inProjects = Reflect.ownKeys(projectsObj).filter(projectKey => projectsObj[projectKey].type == 2); + const inProjects = Reflect.ownKeys(projectsObj).filter(projectKey => { + const project:ProjectInfo =Reflect.get(projectsObj,projectKey) + return project.type == '2' + }); let commonKsxm = ''; checkProjects.forEach(projectCode => { @@ -1133,57 +1213,54 @@ export default class Judge { } }) - const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C53', - drvexam: { - lsh, - kskm: examSubject, - ksxm: project == undefined - ? (commonKsxm - ? (projectsObj[commonKsxm].projectCodeCenter) - : (examSubject == 3 ? 30000 : (xmmcEndCode == undefined ? 10000 : xmmcEndCode))) - : project.projectCodeCenter, - kfxm: kf.markcatalog, - kfxmmx: `${ksxm},${kf.markserial}`, - sfzmhm: idCard, - kchp: encodeURI(carInfo.plateNo), - //扣分方式 - kffs: kf.type == 0 ? 1 : 2, - ksdd: encodeURI(ksdd), - kfsj: time - } + const ksxmD:string = project == undefined + ? (commonKsxm + ? (project.projectCodeCenter) + : (examSubject == '3' ? '30000' : (xmmcEndCode == undefined ? '10000' : xmmcEndCode))) + : project.projectCodeCenter + const drvexam:DrvexamType = { + lsh, + kskm: examSubject, + ksxm:ksxmD, + kfxm: kf.markcatalog, + kfxmmx: `${ksxm},${kf.markserial}`, + sfzmhm: idCard, + kchp: encodeURI(carInfo.plateNo), + //扣分方式 + kffs: kf.type == 0 ? 1 : 2, + ksdd: encodeURI(ksdd), + kfsj: time } + const data:RegulatoryInterfaceParams = {xtlb: '17', jkxlh: serialNumber, jkid: '17C53', drvexam} console.info(judgeTag + 'ksxm=>', data.drvexam.ksxm) - const { code } = await this.sendWriteObjectOut(data, filePath); - if (code == 2300007) { + const temp = await this.sendWriteObjectOut(data, filePath); + if (temp.code == 2300007) { this.isJudgeDisConnect = true } console.info(judgeTag, '项目扣分 end') - promptWxCode('17C53', code) + promptWxCode('17C53',temp.code) } // 评判语音提示 - goJudgeVoice = async (sound: SOUND) => { - const { avPlayer, fileLog } = this; - const { xmdm, code, type } = sound; - console.info('surenjun code=>', JSON.stringify(code)) + goJudgeVoice = async (sound: JudgeSound) => { + const avPlayer = this.avPlayer + const fileLog = this.fileLog + console.info('surenjun code=>', JSON.stringify(sound.code)) //判断是不是模拟灯光语音 - if (type == 1) { - avPlayer.playAudio([`voice/${code[0]}.mp3`], false, () => { - examJudgeSoundEnd({ - itemno: xmdm, code: code[0], type + if (sound.type == 1) { + avPlayer.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { + examJudgeSoundEnd( { + xmdm: sound.xmdm, code: sound.code[0], type: sound.type }) - fileLog.setExamJudgeData({ + fileLog.setExamJudgeData(JSON.stringify({ method: 'examJudgeSoundEnd', - itemno: xmdm, - code: code[0], - type, - }) + itemno: sound.xmdm, + code: sound.code[0], + type:sound.type, + })) }) } else { - avPlayer.playAudio([`voice/${code[0]}.mp3`]) + avPlayer.playAudio([`voice/${sound.code[0]}.mp3`]) } } // 处理考试结束 @@ -1191,17 +1268,30 @@ export default class Judge { this.judgeUI.loadingPopupVisible = true; this.judgeUI.endPopupVisible = false; this.judgeUI.isDeductedPopShow = false; - const { qjjl, dcjl } = ksjs - const { judgeUI, endExam, handleSEP, kfArr, avPlayer, judgeTask, isManual, closeAllFiles } = this; - const { judgeConfigObj, examSubject, isAllProjectsEnd, totalScore, passingScore } = judgeUI; + + const judgeUI = this.judgeUI + const endExam = this.endExam + const handleSEP = this.handleSEP + const kfArr = this.kfArr + const avPlayer = this.avPlayer + const judgeTask = this.judgeTask + const isManual = this.isManual + const closeAllFiles = this.closeAllFiles + + const judgeConfigObj = judgeUI.judgeConfigObj + const examSubject = judgeUI.examSubject + const isAllProjectsEnd = judgeUI.isAllProjectsEnd + const totalScore = judgeUI.totalScore + const passingScore = judgeUI.passingScore + //计算考试分数 // this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0; const singlePlay = AppStorage.get('singlePlay') - const param302 = judgeConfigObj['302']; + const param302:string = Reflect.get(judgeConfigObj, '302') // globalThis.windowClass.setWindowSystemBarEnable(['navigation']) //自动退出待验证并且不合格 - if (!isManual && examSubject == 3 && (param302 == 1 || (singlePlay && param302 == 2)) && + if (!isManual && examSubject == '3' && (param302 == '1' || (singlePlay && param302 == '2')) && totalScore < passingScore) { avPlayer.playAudio([`voice/考试结束.mp3`]) } @@ -1214,13 +1304,10 @@ export default class Judge { }) return } - if (examSubject == 3) { - const param302 = judgeConfigObj['302']; + if (examSubject == '3') { if (totalScore < passingScore) { //考试不合格;考试模式,自动退出; - if (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8) { - - } + if (param302 == '4' || param302 =='5' || param302 == '7' || param302 == '8') {} } else { //考试合格 } @@ -1229,15 +1316,11 @@ export default class Judge { avPlayer.playAudio(['voice/exam_waiting.mp3'], AppStorage.get('singlePlay'), async () => { try { if (!singlePlay) { - const bytes = await this.getMessageHeartbeat(true); - globalThis.judgeUdp.send(bytes) + // TODO const bytes = await this.getMessageHeartbeat(true); + // TODO globalThis.judgeUdp.send(bytes) } } catch (e) { console.info(judgeTag, JSON.stringify(e)) - // setTimeout(() => { - // // avPlayer.avPlayerStop(); - // router.back(); - // }, 3000) } await endExam() }); @@ -1247,53 +1330,60 @@ export default class Judge { public endExam = async (isManual?: Boolean) => { const carInfo = AppStorage.get('carInfo'); const singlePlay = AppStorage.get('singlePlay') - const { examSubject, plateNo } = carInfo; - const { - judgeUI, - ksjs, - getPhoto, - uploadProgressData, - uploadDisConnectData, - avPlayer, - kfArr, - judgeTask, - filePath, - closeAllFiles - } = this; - const { lsh, idCard, serialNumber, kssycs, totalScore, judgeConfigObj, isAllProjectsEnd, passingScore } = judgeUI + const examSubject = carInfo.examSubject + const plateNo = carInfo.plateNo + + const judgeUI = this.judgeUI + const ksjs = this.ksjs + const getPhoto = this.getPhoto + const avPlayer = this.avPlayer + const kfArr = this.kfArr + const filePath = this.filePath + const closeAllFiles = this.closeAllFiles + + const lsh = judgeUI.lsh; + const idCard = judgeUI.idCard; + const serialNumber = judgeUI.serialNumber; + const kssycs = judgeUI.kssycs; + const totalScore = judgeUI.totalScore; + const judgeConfigObj = judgeUI.judgeConfigObj; + const isAllProjectsEnd = judgeUI.isAllProjectsEnd; + const passingScore = judgeUI.passingScore; //TODO 断网考试结束补传 // await uploadDisConnectData(); const time = await GetCurrentTime(); const photoBase64 = await getPhoto(); - const { d1, d2, d3, d4, d5 } = ksjs - const data = { - xtlb: '17', - jkxlh: serialNumber, - jkid: '17C56', - drvexam: { - lsh, - kchp: encodeURI(plateNo), - kskm: examSubject, - sfzmhm: idCard, - zp: photoBase64, - jssj: time, - kscj: (totalScore * 1) > 0 ? totalScore : 0, - kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100), - // 1,22;2,560;3,128;4,0;5,0; - dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'), - } + const d1 = ksjs.d1; + const d2 = ksjs.d2; + const d3 = ksjs.d3; + const d4 = ksjs.d4; + const d5 = ksjs.d5; + + const drvexam:DrvexamType = { + lsh, + kchp: encodeURI(plateNo), + kskm: examSubject, + sfzmhm: idCard, + zp: photoBase64, + jssj: time, + kscj: (totalScore * 1) > 0 ? totalScore : 0, + kslc: Math.ceil(((ksjs?.qjjl + ksjs?.dcjl) || 0) / 100), + // 1,22;2,560;3,128;4,0;5,0; + dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'), } + + const data:RegulatoryInterfaceParams = {xtlb: '17',jkxlh: serialNumber,jkid: '17C56', drvexam} let backTimeOut = setTimeout(() => { router.back() }, 90 * 1000) - const { code, keystr, message } = await this.sendWriteObjectOut(data, filePath); - promptWxCode('17C56', code) + const temp = await this.sendWriteObjectOut(data, filePath); + promptWxCode('17C56',temp.code) - if (code != 1) { + if (temp.code != 1) { avPlayer.playAudio(['voice/监管失败.mp3']) - this.judgeUI.errorMsg = decodeURIComponent(message) + this.judgeUI.errorMsg = decodeURIComponent(temp.message) - if (code == 2300028 || code == 2300007) { + if (temp.code == 2300028 || temp.code == 2300007) { this.judgeUI.errorMsg = '当前的考试过程信息监管审核未通过,程序将退出!' } this.isUdpEnd = true; @@ -1302,66 +1392,64 @@ export default class Judge { return } console.info(judgeTag, '考试结束 end') - const param302 = judgeConfigObj['302']; + const param302:string = Reflect.get(judgeConfigObj,'302') judgeUI.loadingPopupVisible = true; - let currentKssycs = 0; + let currentKssycs = '0'; let voiceURL = '' - if (examSubject == 2) { + if (examSubject == '2') { if (isAllProjectsEnd) { voiceURL = - (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') + (totalScore < passingScore ? `voice/unqualified_${kssycs == '1' ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') } else { - voiceURL = `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` - currentKssycs = kssycs == 1 ? 0 : 1 + voiceURL = `voice/unqualified_${kssycs == '1' ? 'one' : 'two'}.wav` + currentKssycs = kssycs == '1' ? '0' : '1' } switch (voiceURL) { case 'voice/unqualified_one.wav': - currentKssycs = 0; + currentKssycs = '0'; break; case 'voice/unqualified_two.wav': - currentKssycs = 1; + currentKssycs = '1'; break; case 'voice/qualified.mp3': - currentKssycs = 0; + currentKssycs = '0'; break; } } - if (examSubject == 3) { + if (examSubject == '3') { if (isAllProjectsEnd) { if (totalScore < passingScore) { - voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` - currentKssycs = kssycs == 1 ? 0 : 1 + voiceURL = `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` + currentKssycs = kssycs == '1' ? '0' : '1' } else { voiceURL = 'voice/exam_pass.mp3' - currentKssycs = 0 + currentKssycs = '0' } } else { - voiceURL = `voice/${kssycs == 1 ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` - currentKssycs = kssycs == 1 ? 0 : 1 + voiceURL = `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` + currentKssycs = kssycs == '1' ? '0' : '1' } switch (voiceURL) { case 'voice/exam_no_pass_finish.mp3': - currentKssycs = 0; + currentKssycs = '0'; break; case 'voice/exam_no_pass.mp3': - currentKssycs = 1; + currentKssycs = '1'; break; case 'voice/exam_pass.mp3': - currentKssycs = 0; + currentKssycs = '0'; break; } } - const USER = await getSyncData('USER'); - await upDateTableByArray('USER', [{ - ...USER[0], - kssycs: currentKssycs - }]) + const USER = await GetSyncData('USER'); + USER[0].kssycs = currentKssycs + await SqlInsertTable('USER', USER) console.info(judgeTag, `考试成绩:${totalScore}`) if (!singlePlay) { @@ -1371,14 +1459,14 @@ export default class Judge { //语音播放扣分项 let score = 0; //结束考试时候是否播报一遍所有扣分 - const param634 = judgeConfigObj['634']; - if (kfArr.length && ((examSubject == 2 && param634 == 1) || examSubject == 3)) { + const param634:string = Reflect.get(judgeConfigObj,'634') + if (kfArr.length && ((examSubject == '2' && param634 == '1') || examSubject == '3')) { avPlayer.playAudio([`voice/kfdesc.mp3`], false, () => { try { kfArr.forEach((kf, index) => { score += Math.abs(Number(kf.score)); //TODO 考试分数待替换 - if (score <= (examSubject == 3 ? 10 : 20)) { + if (score <= (examSubject == '3' ? 10 : 20)) { if (kfArr.length - 1 === index) { avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => { this.isUdpEnd = true; @@ -1407,20 +1495,20 @@ export default class Judge { this.isUdpEnd = true closeAllFiles() router.back(); - }, param302 == 8 ? 3000 : 0) + }, param302 == '8' ? 3000 : 0) }) } } // 当前项目转换 - getDqxmStr = (type) => { - const projectsObj = this.judgeUI.projectsObj - return projectsObj[type]?.abbreviation || '通用评判' + getDqxmStr:GetDqxmStr = (xmdm) => { + const project:ProjectInfo = Reflect.get(this.judgeUI.projectsObj,xmdm) + return project?.abbreviation || '通用评判' } // 扣分项目转换 - getKfStr = (code) => { + getKfStr:GetKfStr = (code) => { const markRuleListObj = this.judgeUI.markRuleListObj; - const thisMark = markRuleListObj[code] + const thisMark:MarkRule = Reflect.get(markRuleListObj,code) return { desc: thisMark.markshow, score: thisMark.markreal, @@ -1430,175 +1518,173 @@ export default class Judge { } } // 消息心跳发送 - getMessageHeartbeat = async (isEnd?: Boolean) => { - const carInfo = AppStorage.get('carInfo'); - const { examSubject, plateNo, ksyh } = carInfo; - const { - judgeUI, - isExam, - serialIndex, - tempData, - xmmcCode, - xmxh, - xmmcSingleCode, - xmdm, - performInfo, - kfArr, - getTranslateProject, - getSbxh, - fileLog, - } = this; - const singlePlay = AppStorage.get('singlePlay') - const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI; - const { - fourInOneScreen:{ - gpsDigit - } - } = judgeConfig - const examType = examSubject == 2 ? 2 : 3 - const { sensor, gps } = tempData; - if (tempData.sensor === undefined) { - return - } - const { zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, ygq, cs, fdjzs, dw } = sensor - const { jd, wd, hxj, fyj, hbg, sd } = gps; - - //过滤错误数据 - if (jd == 0) { - return - } - const translateProject = getTranslateProject(); - const sbxh = getSbxh(xmdm, xmxh) - const { carzt, dcjl, qjjl, dxjl, bxjl } = performInfo || {}; - const asclshArr = StringToASCII( - fillZero((singlePlay ? (examSubject == 2 ? '0000000000000' : '1111111111111') : lsh) || 0, 13) - ); - //13不足要补0 - const ascksyhArr = StringToASCII(fillZero(ksyh || 0, 13)) - const ascsbxhArr = StringToASCII(sbxh) - const translateSignals = getTranslateSignals( - [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw)) - .concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0]) - ) - const translateJd = convertGpsCoord2(wd).toFixed(gpsDigit) * Math.pow(10, gpsDigit); - const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit) - const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0]) - - let tempSd = ((judgeConfigObj['350'] == 0 ? sd : cs) * 1.852).toFixed(0) * 1 - if (tempSd < 1) { - tempSd = 0 - } - - const arr = [ - //考生号 - asclshArr.map(lsh => string2Bytes(lsh, 8)[0]), - //考试员号 - ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]), - //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 - string2Bytes(`${examType}${AppStorage.get('startHourTime') || startHourTime}`, 4 * 8), - // TODO 消息序号从1开始,0结束 - string2Bytes(isEnd ? 0 : serialIndex, 2 * 8), - /*左向灯 右向灯 双跳灯 远光灯 近光灯 视宽灯 点火1 点火2 离合器 脚刹 手刹 副刹 喇叭 门开关 安全带 档位 车辆状态 雨刮器 雾灯 0*/ - translateSignals, - //速度 发动机转速 GPS纬度 GPS经度 主天线位置 - string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8), - string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8), - //GPS东向距离 - string2Bytes(dxjl < 0 ? (dxjl + 4294967296) : dxjl, 4 * 8), - //GPS北向距离 - string2Bytes(bxjl < 0 ? (bxjl + 4294967296) : bxjl, 4 * 8), - //航向角 俯仰角 高程(海拔) - string2Bytes((hxj) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8), - //项目状态 parseInt('01010010',2) 二进制转成10进制 - translateProjects, - //当前项目编号 - string2Bytes(xmmcSingleCode ? (xmmcSingleCode * 1 + 1) : 0, 8), - //场地设备编号 - ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]), - //本次考试行驶距离 - string2Bytes(Math.floor((dcjl + qjjl) / 100), 2 * 8), - //扣分 - string2Bytes(100 - Math.abs(totalScore), 2 * 8), - //扣分项数量 - string2Bytes(kfArr.length, 8), - //n个扣分序号 - kfArr.map(kf => string2Bytes(kf.kfxh, 8)[0]), - //TODO 牵引车第二gps精度、纬度 - string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8), - //TODO 牵引车第二航向角 - string2Bytes(0, 2 * 8), - //TODO 摩托压线 Byte[20], - string2Bytes(0, 20 * 8), - //考试用时 - string2Bytes(examTime, 4 * 8), - //TODO 项目用时 - string2Bytes(fillZero(0, 2), 2 * 8), - //TODO 设备信号状态 - string2Bytes(0, 4 * 8), - ] - - let tempArr = []; - arr.forEach(itemArr => { - tempArr = tempArr.concat(itemArr) - }) - this.serialIndex += 1; - fileLog.setFourAndOneLogData(`${lsh},${ksyh},${examType}${AppStorage.get('startHourTime') || startHourTime},`); - fileLog.setFourAndOneLogDataBytes(tempArr.toString()); - return Array2Byte(tempArr) - } + // getMessageHeartbeat = async (isEnd?: Boolean) => { + // const carInfo = AppStorage.get('carInfo'); + // const { examSubject, plateNo, ksyh } = carInfo; + // const { + // judgeUI, + // isExam, + // serialIndex, + // tempData, + // xmmcCode, + // xmxh, + // xmmcSingleCode, + // xmdm, + // performInfo, + // kfArr, + // getTranslateProject, + // getSbxh, + // fileLog, + // } = this; + // const singlePlay = AppStorage.get('singlePlay') + // const { lsh, startHourTime, totalScore, examTime, judgeConfigObj } = judgeUI; + // const { + // fourInOneScreen:{ + // gpsDigit + // } + // } = judgeConfig + // const examType = examSubject == 2 ? 2 : 3 + // const { sensor, gps } = tempData; + // if (tempData.sensor === undefined) { + // return + // } + // const { zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, ygq, cs, fdjzs, dw } = sensor + // const { jd, wd, hxj, fyj, hbg, sd } = gps; + // + // //过滤错误数据 + // if (jd == 0) { + // return + // } + // const translateProject = getTranslateProject(); + // const sbxh = getSbxh(xmdm, xmxh) + // const { carzt, dcjl, qjjl, dxjl, bxjl } = performInfo || {}; + // const asclshArr = StringToASCII( + // fillZero((singlePlay ? (examSubject == 2 ? '0000000000000' : '1111111111111') : lsh) || 0, 13) + // ); + // //13不足要补0 + // const ascksyhArr = StringToASCII(fillZero(ksyh || 0, 13)) + // const ascsbxhArr = StringToASCII(sbxh) + // const translateSignals = getTranslateSignals( + // [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw)) + // .concat(getCarStatusType(carzt)).concat([ygq, sensor.wd, 0]) + // ) + // const translateJd = convertGpsCoord2(wd).toFixed(gpsDigit) * Math.pow(10, gpsDigit); + // const translateWd = convertGpsCoord2(jd).toFixed(gpsDigit) * Math.pow(10, gpsDigit) + // const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0]) + // + // let tempSd = ((judgeConfigObj['350'] == 0 ? sd : cs) * 1.852).toFixed(0) * 1 + // if (tempSd < 1) { + // tempSd = 0 + // } + // + // const arr = [ + // //考生号 + // asclshArr.map(lsh => string2Bytes(lsh, 8)[0]), + // //考试员号 + // ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]), + // //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 + // string2Bytes(`${examType}${AppStorage.get('startHourTime') || startHourTime}`, 4 * 8), + // // TODO 消息序号从1开始,0结束 + // string2Bytes(isEnd ? 0 : serialIndex, 2 * 8), + // /*左向灯 右向灯 双跳灯 远光灯 近光灯 视宽灯 点火1 点火2 离合器 脚刹 手刹 副刹 喇叭 门开关 安全带 档位 车辆状态 雨刮器 雾灯 0*/ + // translateSignals, + // //速度 发动机转速 GPS纬度 GPS经度 主天线位置 + // string2Bytes(tempSd * 100, 2 * 8), string2Bytes(fdjzs / 100, 8), string2Bytes(translateJd, 4 * 8), + // string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8), + // //GPS东向距离 + // string2Bytes(dxjl < 0 ? (dxjl + 4294967296) : dxjl, 4 * 8), + // //GPS北向距离 + // string2Bytes(bxjl < 0 ? (bxjl + 4294967296) : bxjl, 4 * 8), + // //航向角 俯仰角 高程(海拔) + // string2Bytes((hxj) * 100, 2 * 8), string2Bytes(fyj * 100, 2 * 8), string2Bytes(hbg * 100, 4 * 8), + // //项目状态 parseInt('01010010',2) 二进制转成10进制 + // translateProjects, + // //当前项目编号 + // string2Bytes(xmmcSingleCode ? (xmmcSingleCode * 1 + 1) : 0, 8), + // //场地设备编号 + // ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]), + // //本次考试行驶距离 + // string2Bytes(Math.floor((dcjl + qjjl) / 100), 2 * 8), + // //扣分 + // string2Bytes(100 - Math.abs(totalScore), 2 * 8), + // //扣分项数量 + // string2Bytes(kfArr.length, 8), + // //n个扣分序号 + // kfArr.map(kf => string2Bytes(kf.kfxh, 8)[0]), + // //TODO 牵引车第二gps精度、纬度 + // string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8), + // //TODO 牵引车第二航向角 + // string2Bytes(0, 2 * 8), + // //TODO 摩托压线 Byte[20], + // string2Bytes(0, 20 * 8), + // //考试用时 + // string2Bytes(examTime, 4 * 8), + // //TODO 项目用时 + // string2Bytes(fillZero(0, 2), 2 * 8), + // //TODO 设备信号状态 + // string2Bytes(0, 4 * 8), + // ] + // + // let tempArr = []; + // arr.forEach(itemArr => { + // tempArr = tempArr.concat(itemArr) + // }) + // this.serialIndex += 1; + // fileLog.setFourAndOneLogData(`${lsh},${ksyh},${examType}${AppStorage.get('startHourTime') || startHourTime},`); + // fileLog.setFourAndOneLogDataBytes(tempArr.toString()); + // return Array2Byte(tempArr) + // } //获取场地序号 - getSbxh = (ksxm, xmxh) => { - const { judgeUI } = this; - const { cdsbInfoObj, projectsObj } = judgeUI; - const project = projectsObj[ksxm] - if (project == 3) { + getSbxh:GetgSbbm = (ksxm, xmxh) => { + const judgeUI = this.judgeUI; + const projectsObj = judgeUI.projectsObj; + const cdsbInfoObj = judgeUI.cdsbInfoObj; + const project:ProjectInfo = Reflect.get(projectsObj, ksxm); + if (judgeUI.examSubject == '3') { return '0000000000' } if (project === undefined) { return '0000000000' } - const projectType = project.sbxh; const projectKey = `${ksxm}_${xmxh}`; - const currentCdsb = cdsbInfoObj[projectKey] || {}; - const sbxh = currentCdsb.sbbh || '0000000000' + const currentCdsb:CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + const sbxh:string = currentCdsb.sbbh || '0000000000' return sbxh } - getSbbm = (ksxm:number, xmxh:string) => { + getSbbm:GetgSbbm = (ksxm, xmxh) => { const judgeUI = this.judgeUI; const cdsbInfoObj = judgeUI.cdsbInfoObj; const projectsObj = judgeUI.projectsObj; - const {examSubject = judgeUI.examSubject; - const project = Reflect.get(projectsObj, ksxm); + const project:ProjectInfo = Reflect.get(projectsObj, ksxm); //科目三不需要 - if (examSubject == 3) { + if (judgeUI.examSubject == '3') { return undefined } if (project === undefined) { return '00000000' } const projectKey = `${ksxm}_${xmxh}`; - const currentCdsb = cdsbInfoObj[projectKey] || {}; - const sbxh = currentCdsb.sbbm || '00000000' - // return sbxh + const currentCdsb:CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + const sbxh:string = currentCdsb.sbbm || '00000000' + return sbxh } // 中心所有项目转换 getTranslateProject = () => { - const { examSubject } = this.judgeUI; - const tempItems = (examSubject == 2 ? testKm2Items : testKm3Items).map(item => { - const current = this.testKmItems[item.code]; - return { - code: item.code, - status: getCenterProjectStatus(current.status) - } + const examSubject = this.judgeUI.examSubject; + const tempItems:TKmItem[] = (examSubject == '2' ? testKm2Items : testKm3Items).map(item => { + const kmItem:KmItem = Reflect.get(this.kmItems,item.code) + const status = getCenterProjectStatus(kmItem.status) + const temp:TKmItem = {code: item.code, status} + return temp }) - const arr = []; + const arr:string[] = []; for (let i = 0; i <= 4; i++) { const temp = tempItems.slice(i * 4, (i + 1) * 4); let tempArr = temp.map(item => item.status) if (i === 4) { - tempArr = examSubject == 2 + tempArr = examSubject == '2' //bit36-bit39保留 ? tempArr.concat(['00', '00']) //bit30-bit39保留 @@ -1613,40 +1699,39 @@ export default class Judge { return arr } // 获取考试项目详情 - getProjectInfo = (projectCode) => { - const judgeUI = this.judgeUI; - return judgeUI.projectsObj[projectCode] + getProjectInfo = (projectCode:number) => { + const project:ProjectInfo = Reflect.get(this.judgeUI.projectsObj, projectCode) + return project } // 获取模型数据 - getModelData = (modelName) => { - const modelPath = this.modelPath - const fileModel = this.fileModel; - const modelData = fileModel.getModelContent(modelPath, modelName); + getModelData = (modelName:string) => { + const modelData = this.fileModel.getModelContent(this.modelPath, modelName); return modelData } // 统计必考项目、所有项目、已考数量 setCountItems = async () => { - const carInfo = AppStorage.get('carInfo'); - const { examSubject } = carInfo; - const { projectsObj } = this.judgeUI; + const projectsObj = this.judgeUI.projectsObj; //必考项目数量 必考项目已考数量 let projectNum = 0, endProjectsNum = 0; // 所有考试项目数量 项目已考项目数量 let allProjectNum = 0, allEndProjectsNum = 0; Reflect.ownKeys(projectsObj).forEach(projectKey => { - const { type, isRequired } = projectsObj[projectKey]; + const projectObj:ProjectInfo = Reflect.get(projectsObj, projectKey) + const type = projectObj.type + const isRequired = projectObj.isRequired allProjectNum += 1; - if (type == 3 || type == 4) { + if (type == '3' || type == '4') { allEndProjectsNum += 1; } if (isRequired) { projectNum += 1; - if (type == 3 || type == 4) { + if (type == '3' || type == '4') { endProjectsNum += 1; } } }) + console.info(judgeTag, '项目状态projectsObj:' + JSON.stringify(projectsObj)); console.info(judgeTag, '所有考试项目数量:' + allProjectNum) console.info(judgeTag, '必考项目数量:' + projectNum) @@ -1656,9 +1741,8 @@ export default class Judge { this.judgeUI.isAllProjectsEnd = (allProjectNum - allEndProjectsNum === 0) } // 检测差分状态 - checkDwzt = async (type) => { - const { avPlayer } = this; - const judgeConfig = this.judgeUI.judgeConfig; + checkDwzt = async (type:number) => { + const avPlayer = this.avPlayer; switch (type) { case 0: this.judgeUI.isDwztRight = true; @@ -1695,8 +1779,14 @@ export default class Judge { //开始评判 private async judging(callBack: Function) { - const { judgeUI } = this; - const { name, lsh, idCard, kssycs, manualMarkRules } = judgeUI; + const judgeUI = this.judgeUI; + + const name = judgeUI.name + const lsh = judgeUI.lsh + const idCard = judgeUI.idCard + const kssycs = judgeUI.kssycs + const manualMarkRules = judgeUI.manualMarkRules + const fileLog = new FileLog(judgeUI.context); const filePath = await fileLog.initFileLogo({ name, lsh, idCard @@ -1704,34 +1794,32 @@ export default class Judge { this.fileLog = fileLog; this.filePath = filePath; - const { - getJudgeBeginData, - handleUdp, - handDistance, - fileUtil, - handleTrajectoryUdp, - isTrajectoryOpen, - trajectoryPath, - avPlayer - } = this; - const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); - let strArr = []; + const getJudgeBeginData = this.getJudgeBeginData; + const handleUdp = this.handleUdp; + const handDistance = this.getJudgeBeginData; + const handleTrajectoryUdp = this.handleTrajectoryUdp; + const isTrajectoryOpen = this.isTrajectoryOpen; + const trajectoryPath = this.trajectoryPath; + const avPlayer = this.avPlayer; + + const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); + let strArr:string[] = []; if (isTrajectoryOpen) { const folderPath = await this.fileUtil.initFolder(trajectoryPath); - const str = await fileUtil.readFile(folderPath) + const str:string = await this.fileUtil.readFile(folderPath) strArr = str.split('\n') } //日志回调 console.info(judgeTag, '1.进入评判入口') - await examJudgeSetLogCallback(3, async (level, info, len) => { + await examJudgeSetLogCallback(3, async (level:number, info:string, len:number) => { console.log('评判日志:' + info) await fileLog.setExamJudgeLogData(info); }) console.info(judgeTag, '2.注册日志回调完成') - let initInfo = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); - await fileLog.setExamJudgeData(initInfo) + let initInfo:JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); + await fileLog.setExamJudgeData(JSON.stringify(initInfo)) //相关评判初始化只做一次 if (!isJudgeInitBool) { const tempJudge = await examJudgeInit(initInfo); @@ -1740,37 +1828,39 @@ export default class Judge { } AppStorage.setOrCreate('isJudge', true) // 2.评判过程回调 - await examJudgeSetRealExamCallback(async (strData, len) => { + await examJudgeSetRealExamCallback(async (strData:string, len:number) => { await fileLog.setExamJudgeCallbackData(strData) console.info('评判回调数据', strData) this.handleRealExam(strData, callBack) }) - await examJudgeSetPerformCallback(async (info) => { + await examJudgeSetPerformCallback(async (info:string) => { console.info('评判实时数据', info) - const performInfo = JSON.parse(info) + const performInfo:JudgePerformInfo = JSON.parse(info) this.performInfo = performInfo const jl = Math.floor((performInfo.qjjl + performInfo.dcjl) / 100); - if (jl > this.judgeUI.examMileage) { + if (jl > Number(this.judgeUI.examMileage)) { this.checkExamIsEnd() } this.judgeUI.jl = jl //TODO 待优化 跨组件传值不生效 - globalThis.laneData = performInfo.lane; + // globalThis.laneData = performInfo.lane; }) + let beginExamInfo:JudgeBeginObj = undefined // 3.开始考试 - let beginExamInfo = isTrajectoryOpen ? { - ...JSON.parse(strArr[1]), - replay: 1, - } : await getJudgeBeginData() - - await fileLog.setExamJudgeData(beginExamInfo) + if(isTrajectoryOpen){ + beginExamInfo = JSON.parse(strArr[1]) + beginExamInfo.replay = 1 + }else{ + beginExamInfo = await getJudgeBeginData() + } + await fileLog.setExamJudgeData(JSON.stringify(beginExamInfo)) await examJudgeBeginExam(beginExamInfo); console.info(judgeTag, '6.开始考试注册完成') - avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) + avPlayer.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3']) - if (!globalThis.singlePlay) { + if (!judgeUI.singlePlay) { this.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, this.context) } @@ -1793,34 +1883,37 @@ export default class Judge { } // 处理实时udp里的plc信号 // globalThis.udpClient.closeMessage_1(); - globalThis.udpClient.onMessage_1(async (msg) => { - console.info('socketTag[PLC.UdpClient]', '收到udp回调数据') - handleUdp(msg) - const udpIndex = globalThis.udpIndex; - if (udpIndex % 5 === 0) { - handDistance(); - } - }); + //TODO UDP修改 + // globalThis.udpClient.onMessage_1(async (msg) => { + // console.info('socketTag[PLC.UdpClient]', '收到udp回调数据') + // handleUdp(msg) + // const udpIndex = globalThis.udpIndex; + // if (udpIndex % 5 === 0) { + // handDistance(); + // } + // }); // this.checkExamIsEnd() - //监听远程结束考试 - globalThis.udpEvent.onEndExam(async () => { - this.checkExamIsEnd(true); - }) + //TODO 监听远程结束考试 + // globalThis.udpEvent.onEndExam(async () => { + // this.checkExamIsEnd(true); + // }) console.info(judgeTag, JSON.stringify(manualMarkRules)) - //监听远程扣分 - globalThis.udpEvent.onKfExam(async (content) => { - console.info('评判收到远程扣分项目内容' + JSON.stringify(content)) - const { kfxh, directives } = content.data; - console.info(judgeTag, '评判收到远程扣分项目内容,扣分序号:' + `kfxh=>${kfxh}; directives=>${directives}`) - //根据扣分序号找扣分代码 - const currentKf = manualMarkRules.filter(mark => mark.kfxh == kfxh)[0]; - console.info(judgeTag, '扣分项目:' + JSON.stringify(currentKf)) - this.setJudgeMark(currentKf.itemno, currentKf.markserial, 2); - globalThis.judgeUdp.confirmKf(directives, 1) - }) + //TODO 监听远程扣分 + // globalThis.udpEvent.onKfExam(async (content:JudgeUdpKf) => { + // console.info('评判收到远程扣分项目内容' + JSON.stringify(content)) + // const kfxh = content.data.kfxh; + // const directives = content.data.directives; + // console.info(judgeTag, '评判收到远程扣分项目内容,扣分序号:' + `kfxh=>${kfxh}; directives=>${directives}`) + // //根据扣分序号找扣分代码 + // const currentKf:MarkRule = manualMarkRules.filter(mark => mark.kfxh == kfxh)[0]; + // console.info(judgeTag, '扣分项目:' + JSON.stringify(currentKf)) + // this.setJudgeMark(String(currentKf.itemno), currentKf.markserial, 2); + // //TODO + // //globalThis.judgeUdp.confirmKf(directives, 1) + // }) this.checkExamIsEnd(); } diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets b/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets index 38246512..02b716f8 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeCommon.ets @@ -4,7 +4,7 @@ import { GetCurrentTime, NumberToByteArray } from '../../../utils/Common'; import systemTime from '@ohos.systemDateTime'; import { Array2Byte } from './Common'; import { CarInfoType } from '../../../model'; -import { Gps, Lane,Plc,Vision,Radar, Sensor,DefaultJudgeConfigObj} from '../../../model/Judge' +import { Gps, Lane,Plc,Vision,Radar, Sensor,DefaultJudgeConfigObj, JudgeLane} from '../../../model/Judge' interface Extend {} @@ -72,7 +72,7 @@ export function getDwStatusType(dw?:number) { // 中心实时项目状态转换 -export function getCenterProjectStatus(status?:number) { +export function getCenterProjectStatus(status?:number):string { switch (status) { //不考 case 0: @@ -98,8 +98,8 @@ export function getKmProjectVoice( // 1:项目开始 2:项目结束 type: 1 | 2, judgeConfig:object, - lane:Lane, - xmxh:number + lane:JudgeLane, + xmxh:string ) { const carInfo = AppStorage.get('carInfo'); const examSubject = carInfo.examSubject;