diff --git a/entry/src/main/ets/model/Judge.ets b/entry/src/main/ets/model/Judge.ets index b4ee395a..7a0f8809 100644 --- a/entry/src/main/ets/model/Judge.ets +++ b/entry/src/main/ets/model/Judge.ets @@ -554,7 +554,7 @@ export interface TKmItem { status: string } -export interface KmItems { +export interface JudgeConfigObjKmItems { '1'?: KmItem } @@ -601,12 +601,12 @@ export interface JudgeInitObj extends Km3JudgeInitConfig { } -export interface JudgeKsxm { +export interface JudgeKSXM { xmdm: number xmxh: string } -export interface JudgeKfxm { +export interface JudgeKFXM { xmdm: number kfdm: string } @@ -631,21 +631,21 @@ export interface JudgeBeginObj { czlx: number kskssj: number passing: number - ksxm: JudgeKsxm[] + ksxm: JudgeKSXM[] ddxk: 0 | 1 ddkssj: number ykxm: number[] - kfxm: JudgeKfxm[] + kfxm: JudgeKFXM[] yklc: number special?: number[] sczb?: 0 | 1 - sczbkf?: JudgeKfxm[] + sczbkf?: JudgeKFXM[] dmndg: boolean mfxx: boolean mfxxn: boolean } -export interface JudgeXmjs { +export interface JudgeXMJS { xmdm: number xmxh: string xmhg: 0 | 1 @@ -685,7 +685,7 @@ export interface JudgeEventKf { type?: 0 | 1 | 2 | 3 } -export interface JudgeKsjs { +export interface JudgeKSJS { type: 0 | 1 qjjl: number dcjl: number @@ -715,7 +715,7 @@ export interface JudgeLane { count: number } -export interface JudgeNongps { +export interface JudgeNonGPS { type: 0 | 1 | 2 | 3 | 4 } @@ -774,16 +774,16 @@ 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 + xmks: JudgeKSXM + xmjs: JudgeXMJS kf: JudgeKf - ksjs: JudgeKsjs - xmqx: JudgeKsxm + ksjs: JudgeKSJS + xmqx: JudgeKSXM sound: JudgeSound mndg: string lane: JudgeLane - precast: JudgeKsxm - nongps: JudgeNongps + precast: JudgeKSXM + nongps: JudgeNonGPS } export interface Km3JudgeInitConfig { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index e370160b..8858543e 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,8 +1,7 @@ import common from '@ohos.app.ability.common'; import router from '@ohos.router'; -// import { initJudgeUdp } from '../common/utils/UdpJudge'; -import { judgeConfig } from './judgeSDK/utils/judgeConfig'; +import { JudgeConfig } from './judgeSDK/utils/judgeConfig'; import promptAction from '@ohos.promptAction'; import errorMsgDialog from './compontents/errorMsgDialog'; import imageBtn from './compontents/imageBtn'; @@ -23,8 +22,8 @@ import { GetCurrentTime } from '../utils/Common'; import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness'; import { CenterUDPClientInstance } from '../utils/business/CenterUdpBusiness'; import { DrivingDataStorage } from '../utils/business/DrivingDataStorage'; -import { initJudgeUdp } from '../utils/business/UdpJudge'; -import { centerUDPClient, judgeUDPClient, lightUDPClient, objUDPClient } from '../utils/UdpUtils'; +import { JudgeUdpBusinessInstance } from '../utils/business/JudgeUdpBusiness'; +import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; @Entry @@ -32,7 +31,7 @@ import { centerUDPClient, judgeUDPClient, lightUDPClient, objUDPClient } from '. struct Index { @State url: string = '' @State hasAuth: boolean = false; - @State dialogVisiable: boolean = false; + @State dialogVisible: boolean = false; @State singlePlay: boolean = false; @State baseInfo: BaseInfoType = {}; @State deviceId: string = ''; @@ -69,13 +68,14 @@ struct Index { this.ratio = AppStorage.get('ratio') this.initParamFlag = false this.delLoading = false - this.dialogVisiable = false + this.dialogVisible = false this.angle = 0 this.loading = false AppStorage.set('lsh', '1111111111111') // TODO 未改 // globalThis.errorDialog = this.errorDialog // globalThis.udpEvent = new UdpEvent(); + JudgeEmitterInstance.init() GetSyncData("MA_SYSSET").then((res: MASYSSETTableType[]) => { res.forEach((element) => { if (element.v_no === "305") { @@ -84,6 +84,10 @@ struct Index { } }); }); + + } + + async onPageShow(): Promise { this.singlePlay = AppStorage.get('singlePlay') this.baseInfo = AppStorage.get('baseInfo') @@ -96,12 +100,6 @@ struct Index { this.context.resourceManager.getRawFileContent("welcome.wav") .then(() => { this.avPlayer.playAudio(['welcome.wav']) - - // this.vocObj.playAudio({ - // type: 1, - // name: 'welcome.wav' - // }) - // let rawFile = value; }) .catch((error: BusinessError) => { console.log("getRawFileContent promise error is " + error); @@ -114,6 +112,15 @@ struct Index { AppStorage.setOrCreate('lsh', '1111111111111') } + @Styles + commStyle(){ + .width(220 * this.ratio * this.dialogRatio) + .height(69 * this.ratio * this.dialogRatio) + .backgroundImage($r('app.media.button_nor')) + .backgroundImageSize({ width: '100%', height: '100%' }) + // .margin({ bottom: 12 * this.ratio }) + } + async testXMLToJSONInWorker() { if (this.loading) { return @@ -225,7 +232,7 @@ struct Index { setTimeout(() => { this.initParamFlag = true }, 3000) - initJudgeUdp() + JudgeUdpBusinessInstance.init() // TODO 摄像头遮挡 // takePhotoFn(this.context) clearInterval(this.interval) @@ -239,15 +246,6 @@ struct Index { this.createAlbum() } - @Styles - commStyle(){ - .width(220 * this.ratio * this.dialogRatio) - .height(69 * this.ratio * this.dialogRatio) - .backgroundImage($r('app.media.button_nor')) - .backgroundImageSize({ width: '100%', height: '100%' }) - // .margin({ bottom: 12 * this.ratio }) - } - build() { Column() { Column() { @@ -274,7 +272,7 @@ struct Index { // type: 1, // name: 'button_media.wav' // }) - this.dialogVisiable = true + this.dialogVisible = true }) } } @@ -339,7 +337,7 @@ struct Index { // type: 1, // name: 'button_media.wav' // }) - if (judgeConfig.isTrajectoryOpen) { + if (JudgeConfig.isTrajectoryOpen) { router.pushUrl({ url: 'pages/UserInfo', }, router.RouterMode.Single) @@ -420,7 +418,7 @@ struct Index { } // - if (this.dialogVisiable) { + if (this.dialogVisible) { Flex({ justifyContent: FlexAlign.Center }) { Text('确认是否退出应用') .fontSize(28 * this.ratio * this.dialogRatio) @@ -434,7 +432,7 @@ struct Index { } .commStyle() .onClick(() => { - this.dialogVisiable = false + this.dialogVisible = false // this.vocObj.playAudio({ // type: 1, // name: 'button_media.wav' diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 8fe6ac64..9dc627c7 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -1,1466 +1,1466 @@ -// import router from '@ohos.router'; -// import Prompt from '@system.prompt'; -// import common from '@ohos.app.ability.common'; -// import EndPoPup from './compontents/judge/EndPopup'; -// import LoadingPopup from './compontents/judge/LoadingPopup'; -// import DeductedPopup from './compontents/judge/DeductionPopup'; -// import AmplifyPopup from './compontents/judge/AmplifyPopup'; -// import Judge from './judgeSDK/judge'; -// import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon'; -// import { uploadExamMileage } from '../api/judge'; -// import DwztErrorPopup from './compontents/judge/DwztErrorPopup'; -// import MsgPopup from './compontents/judge/MsgPopup'; -// import { -// CARINFO, -// CDSBInfo, -// LANE, -// MAPITEMPOINTITEM, -// MAPPOINT, -// MarkRule, -// Project, SYSTEMPARMARR -// } from './judgeSDK/api/judgeSDK.d'; -// -// import { judgeConfig } from './judgeSDK/utils/judgeConfig'; -// -// import SignDisplayCom from './compontents/signDisplayCom'; -// import { -// AmplifyItem, -// CarInfoType, -// CDSBInfos, DefaultJudgeConfigObj, -// ES_CARINFOType, -// ItemInfos, -// JudgeBeginObj, -// JudgeCallBacData, -// JudgeInitObj, -// JudgeUI, MA_CDSBINFOType, -// MA_ITEMINFOType, -// MA_MAP_POINT_ITEMType, -// MA_MAP_POINTType, MA_SYSTEMPARMType, -// MarkRules, -// MASYSSETTableType, ProjectInfo, -// ProjectInfos, -// ProjectRoads, -// RouteParamsType, -// SYSSET, -// SyssetConfig, User -// } from '../model'; -// import { GetSyncData } from '../utils/table/Operation'; -// import dayTs from '../utils/Date'; -// import { GetCurrentTime } from '../utils/Common'; -// import { chunkArr } from './judgeSDK/utils/Common'; -// import FileUtils from '../utils/FileUtils'; -// -// -// @Entry -// @Component -// struct Index { -// scroller: Scroller = new Scroller() -// //页面通用字体大小 -// @State wayno: number = 0 -// @State FONTSIZE: number = 30 -// @State BIGFONTSIZE: number = 32 -// //结束考试弹窗 -// @State endPopupVisible: boolean = false -// //等待弹窗(考试及格,考试不及格使用) -// @State loadingPopupVisible: boolean = false -// //实时轨迹弹窗 -// @State signDisplayComVisible: boolean = false -// @State isDdxk: boolean = false; -// @State time: string = '' -// //考试用时 -// @State examTime: number = 0 -// //开始时间 -// @State startTime: string = '00:00:00' -// @State startFullTime: string = '' -// @State startHourTime: string = '' -// @State startExamTime: string = '' -// //科目类型 -// @State examSubject: string = '3'; -// @State ddxkTime: number = 0; -// @State ddxkKsxmArr: string[] = [] -// @State ddxkKfArr: string[] = [] -// @State xmmcStr: string = '' -// @State carztStr: string = '' -// @State kfArr: MarkRule[] = [] -// @State name: string = '' -// @State idCard: string = '' -// @State singlePlay: boolean = false; -// @State totalScore: number = 100 -// //模拟考试项目 -// @State projects: ProjectInfo[] = [] -// @State projectsObj: ProjectInfos = {} -// @State projectsCenterObj: ProjectInfos = {} -// @State markRuleListObj: MarkRules = {} -// @State cdsbInfoObj?: CDSBInfos = {} -// @State itemInfoObj?: ItemInfos = {} -// @State timer: number = 0 -// @State judgeConfig: SyssetConfig[] = [] -// @State judgeConfigObj: DefaultJudgeConfigObj = defaultJudgeConfigObj -// //流水号 -// @State lsh: string = '' -// @State kszp: string = '' -// @State ksdd: string = '' -// @State kssycs: string = '' -// @State ksxl: string = '' -// @State kslx: string = '' -// //监管线路代码 -// @State xldm: string = '' -// //监管接口序列号 -// @State serialNumber: string = '' -// @State syssetParam623: boolean = false; -// @State syssetParam211: string = ''; -// @State carType: string = '' -// @State carName: string = '' -// @State isDeductedPopShow: boolean = false -// @State isAmplifyPopShow: boolean = false -// @State amplifiedImgIndex: number = 0 -// judge: Judge -// //行驶距离 -// @State jl: number = 0 -// //应考里程 -// @State examMileage: string = '0' -// @State artSubject3Projects: string[] = ['直线', '会车', '变道', '超车', '掉头', '停车'] -// @State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4', '10', '12', '11'] -// @State manualMarkRules: MarkRule[] = [] -// //科目三评判初始化数据 -// @State systemparmArr: SYSTEMPARMARR[] = [] -// @State mapPointItemArr: MAPITEMPOINTITEM[] = [] -// @State carinfoArr: CARINFO[] = [] -// @State mapPointArr: MAPPOINT[] = [] -// //手动项目是否在进行中 -// @State isManualProjectIn: boolean = false; -// //项目是否进行中 -// @State isProjectIn: boolean = false; -// //正在进行的项目代码 -// @State currentXmdm?: number = 0 -// // 必考项目除靠边停车是否全部完成 -// @State isRequiredProjectsEnd: boolean = false; -// @State isAllProjectsEnd: boolean = false; -// @State draw: boolean = false; -// @State lane: LANE = { road: '', num: 0, count: 0 } -// //定位差分状态时候正常 -// @State isDwztRight: boolean = true; -// @State defaultTabIndex: number = 0; -// public kfArrScroller: Scroller = new Scroller() -// //档位 -// @State dw: string = '' -// //速度 -// @State sd: string = '' -// @State mileageTimer: number = 0; -// @State passingScore: number = 80 -// @State dwztErrorVisible: boolean = false; -// @State popTimer: number = 0; -// @State carlist: string = '' -// @State errorMsg: string = '' -// @State carInfo: CarInfoType = {} -// @State isErrorMsgEnd: boolean = false -// @State disConnectErrorOpen: boolean = false -// public context = getContext(this) as common.UIAbilityContext; -// -// async aboutToDisappear() { -// clearInterval(this.mileageTimer) -// } -// -// async aboutToAppear() { -// const time = GetCurrentTime() -// this.carInfo = AppStorage.get('carInfo') -// this.singlePlay = AppStorage.get('singlePlay') -// this.startTime = time.split(' ')[1] -// this.startFullTime = GetCurrentTime(1); -// // this.startHourTime = await getCurrentHourTime() -// this.startTime = dayTs().format("HHmmssSSS") -// this.startExamTime = time -// setInterval(async () => { -// this.time = GetCurrentTime(); -// this.examTime += 1; -// }, 1000); -// //初始化数据库表 -// await this.initDb() -// //断点续考 -// await this.goDdxkItems() -// //初始化评判 -// const judge = await this.initJudge(); -// this.judge = judge -// } -// -// //初始化相关数据库表 -// async initDb() { -// this.examSubject = this.carInfo.examSubject; -// // const { isTrajectoryOpen, trajectoryPath } = judgeConfig -// await this.initStudent(); -// await this.initCar(); -// -// //是否开启轨迹回放模式 -// if (judgeConfig.isTrajectoryOpen) { -// this.initTrajectoryParam(judgeConfig.trajectoryPath) -// } else { -// await this.initSystemParam() -// await this.initMarkRules(); -// await this.initSysset(); -// } -// await this.initCDSBInfo() -// await this.initItemInfo() -// -// // 科目三新增读取表数据 -// if (this.examSubject == '3') { -// await this.initMapPoint() -// await this.initMapPointItem() -// //定时上传考试里程 -// // let mileageTimer = setInterval(()=>{ -// // this.uploadMileage() -// // },5000) -// // this.mileageTimer = mileageTimer -// } -// } -// -// // 查询考车信息 -// async initCar() { -// // const result = await getSyncData('ES_CARINFO') -// const result = await GetSyncData("ES_CARINFO") -// const carInfo = result[0] || {}; -// this.carName = decodeURI(carInfo.carclass) -// this.carType = carInfo.kscx -// this.carinfoArr.push({ -// CARID: carInfo.carid, -// IPADDR: '', -// CARCLASS: decodeURI(carInfo.carclass), -// KSCX: carInfo.kscx, -// // CARNAME: decodeURI(carInfo.carname), -// CARNAME: "", -// FLAG: carInfo.flag, -// BK1: carInfo.bk1, -// BK2: carInfo.bk2, -// }) -// console.info('surenjun =>carinfoArrr', JSON.stringify(this.carinfoArr)) -// } -// -// // 获取考生信息 -// async initStudent() { -// const students = await GetSyncData('USER') -// const stuInfo = students[0]; -// this.name = stuInfo.xm || '测试考生'; -// this.idCard = stuInfo.sfzmhm || '01234567891010'; -// this.lsh = this.singlePlay ? '0000000000000' : stuInfo.lsh; -// this.kszp = stuInfo.kszp; -// this.ksdd = stuInfo.ksdd; -// this.kssycs = stuInfo.kssycs; -// this.ksxl = stuInfo.ksxl; -// this.wayno = Number(stuInfo.ksxl); -// this.xldm = stuInfo.xldm; -// this.kslx = stuInfo.kslx; -// } -// -// // 获取扣分代码信息 -// async initMarkRules(markRules ?: MarkRule[]) { -// const markRuleParams = markRules || await GetSyncData('MA_MARKRULE') -// -// markRuleParams.forEach(mark => { -// const tempObj: MarkRule = { -// itemno: mark.itemno * 1, -// markcatalog: mark.markcatalog, -// markshow: decodeURI(mark.markshow), -// markreal: mark.markreal * 1, -// markserial: mark.markserial, -// kfxh: mark.kfxh, -// OnlyOneKind: mark.onlyoneid * 1, -// NoCancelId: mark.nocancelid * 1, -// GPS_SID: mark.gps_sid == 0 ? false : true -// } -// -// //筛选出人工评判的扣分 -// if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) { -// this.manualMarkRules.push(tempObj) -// } -// tempObj.markserial = mark.markserial -// Reflect.set(this.markRuleListObj, `${mark.itemno}_${mark.markserial}`, tempObj) -// }) -// } -// -// // 考试项目是否全部完成 -// -// // 获取sysset表信息 -// async initSysset(sysset?: SYSSET[]) { -// const syssetParams: SYSSET[] | MASYSSETTableType[] = sysset || await GetSyncData('MA_SYSSET') -// const serialNumberArr = (syssetParams as SYSSET[]).filter(sys => sys.v_no === '901'); -// console.info('surenjun serialNumberArr' + JSON.stringify(serialNumberArr)) -// this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || ''; -// // const { isTrajectoryOpen } = judgeConfig -// const syssetJudgeConfigArr: SyssetConfig[] = [] -// -// syssetParams.forEach((sys: SYSSET) => { -// if (judgeConfig.isTrajectoryOpen) { -// sys.v_no = String(sys.key); -// sys.v_name = sys.name; -// sys.v_value = sys.value -// } -// -// // const { v_no, v_value } = sys; -// const v_no_num = Number(sys.v_no) -// const value = decodeURIComponent(sys.v_value) -// if (v_no_num >= 10 && v_no_num <= 900) { -// const name = -// syssetJudgeConfigArr.push({ -// key: v_no_num, value: value, -// name: decodeURI(sys.v_name) -// }) -// } -// -// //623 考试中是否可以查看轨迹画面(0-否+1-是) -// if (sys.v_no == '623') { -// this.syssetParam623 = value == '1' ? true : false -// } -// -// //科目三应行驶距离参数 -// if (sys.v_no == '303') { -// this.examMileage = this.examMileage == '0' ? (sys.v_value + '') : this.examMileage; -// } -// -// // //地点版本参数 -// // if (sys.v_no == '211') { -// // this.syssetParam211 = decodeURIComponent(sys.v_value + '') -// // } -// -// //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) -// if (sys.v_no == '364' && sys.v_value == "2") { -// let currentParams: RouteParamsType = router.getParams() as RouteParamsType; -// // const { sczb, kfdm } = currentParams; -// const kfdm = currentParams.kfdm; -// currentParams.kfdm.forEach(kf => { -// // const { xmdm, kfdm } = kf -// -// const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${kf.xmdm}_${kf.kfdm}`) -// const currentProject: ProjectInfo = Reflect.get(this.projectsObj, kf.xmdm) -// -// // 过滤考前绕车一周上车准备的扣分 -// if (currentParams.sczb == "1" && kf.xmdm == 1) { -// return -// } -// -// this.kfArr.push({ -// //扣分项目名称 -// xmmcStr: currentProject.name, -// xmdm: kf.xmdm, -// desc: currentKf.markshow, -// score: currentKf.markreal, -// markcatalog: currentKf.markcatalog, -// markserial: currentKf.markserial, -// kfxh: currentKf.kfxh -// }) -// this.totalScore += currentKf.markreal * 1; -// }) -// const project_1 = Reflect.get(this.projectsObj, 1) -// project_1.type = kfdm.length ? '4' : '3'; -// Reflect.set(this.projectsObj, 1, project_1) -// -// } -// Reflect.set(this.judgeConfigObj, sys.v_no, value) -// }); -// this.judgeConfig = syssetJudgeConfigArr; -// } -// -// //初始化systemParam表 -// async initSystemParam(sysParam?: MA_SYSTEMPARMType[]) { -// let systemParms: MA_SYSTEMPARMType[] = sysParam || await GetSyncData('MA_SYSTEMPARM') -// -// let currentParams: RouteParamsType = router.getParams() as RouteParamsType; -// // const { carName, carType, examSubject } = this; -// //小车车型列表 -// const sCarTypes = ['C1', 'C2', 'C5'] -// if (this.singlePlay) { -// this.wayno = Number(currentParams.wayno) || 1; -// } -// //真实监管下发的项目 -// let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item); -// console.info('surenjun kStringArr', JSON.stringify(kStringArr)) -// let isInExam = kStringArr.length > 0; -// // const { isTrajectoryOpen } = judgeConfig -// let carNo = '', allItems: string[] = []; -// systemParms.forEach((systemParm) => { -// if (judgeConfig.isTrajectoryOpen) { -// systemParm.no1 = systemParm.NO1 + ''; -// systemParm.no2 = systemParm.NO2 + ''; -// systemParm.no3 = systemParm.NO3 + ''; -// systemParm.txt1 = systemParm.TXT1; -// systemParm.txt2 = systemParm.TXT2; -// systemParm.txt3 = systemParm.TXT3; -// } -// // const { no1, no2, no3, } = systemParm; -// const txt1 = decodeURI(systemParm.txt1) -// const txt2 = decodeURI(systemParm.txt2) -// -// const no1 = systemParm.no1; -// const no2 = systemParm.no2; -// const no3 = systemParm.no3; -// -// //获取当前考车的no2 -// if (systemParm.no1 == "3" && systemParm.no3 == "1") { -// if (txt1 === this.carName) { -// carNo = systemParm.no2 -// this.carlist = carNo -// } -// } -// -// //获取及格分数线 -// if (systemParm.no1 == "3" && systemParm.no3 == "3" && carNo === systemParm.no2) { -// this.passingScore = Number(txt1) || 0; -// } -// //根据车型获取应行驶里程数 -// if (systemParm.no1 == "3" && systemParm.no3 == "15" && carNo === systemParm.no2) { -// this.examMileage = ((decodeURI(systemParm.txt1)) || '').split('^')[0]; -// } -// //获取当前考车的考试项目 -// if (carNo !== '' && systemParm.no1 == "3" && systemParm.no2 == carNo && systemParm.no3 == "10") { -// allItems = decodeURIComponent(systemParm.txt1).split(',').filter(txt => txt !== '') -// console.info('surenjun', JSON.stringify(allItems)) -// } -// if ( -// //科目二获取项目 -// (this.examSubject == "2" && allItems.length && systemParm.no1 == '6' && allItems.includes(systemParm.no2)) -// || -// //科目三获取项目 -// (this.examSubject == "3" && systemParm.no1 == "6") -// ) { -// const name = decodeURI(systemParm.txt1) -// //小车过滤掉 夜间模拟行驶 -// if (sCarTypes.includes(this.carType) && name === '夜间行驶') { -// return -// } -// const currentProject: ProjectInfo = { -// name, -// abbreviation: decodeURI(systemParm.txt3), -// projectCode: no2, -// projectCodeCenter: txt2, -// //是否是必考 加减档设置成非必考 -// isRequired: no2 == '14' ? false : allItems.includes(no2 + ''), -// //是否考过了 -// isEnd: false, -// //项目开始数据是否上传过 -// isUpload: false, -// } -// const no2Num = Number(systemParm.no2) -// //真实监管下发考试项目 -// if (isInExam && !(kStringArr.includes(txt2) || kStringArr.includes(no2 + ''))) { -// console.info('surenjun =>', txt2) -// console.info('surenjun => no2', systemParm.no2) -// currentProject.type = '3' -// currentProject.isUpload = true -// currentProject.isEnd = true -// this.ddxkKsxmArr.push(txt2) -// } -// Reflect.set(this.projectsObj, no2Num, currentProject) -// Reflect.set(this.projectsCenterObj, txt2, currentProject) -// this.projects.push(currentProject); -// } -// -// this.systemparmArr.push({ -// 'NO1': Number(systemParm.no1), -// 'NO2': Number(systemParm.no2), -// 'NO3': Number(systemParm.no3), -// 'TXT1': decodeURIComponent(systemParm.txt1), -// 'TXT2': decodeURIComponent(systemParm.txt2), -// 'TXT3': decodeURIComponent(systemParm.txt3), -// }) -// }) -// const projects = this.projects; -// console.info('surenjun', JSON.stringify(this.ddxkKsxmArr)) -// -// if (!projects.length) { -// Prompt.showToast({ -// message: '读取数据库信息失败,请重新联网更新!', -// duration: 8000 -// }); -// router.back(); -// } -// } -// -// // 获取场地设备信息 -// async initCDSBInfo() { -// const cdsbParams: MA_CDSBINFOType[] = await GetSyncData('MA_CDSBINFO') -// //只记录考试项目的模型 -// const projectsObj = this.projectsObj -// cdsbParams.forEach((cdsb) => { -// const key = decodeURI(cdsb.itemsno) -// const newKey = key.split('~').join('_') -// const xmdm = Number(key.split('~')[0]) -// const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) -// if (currentProject) { -// const cdsbInfo: CDSBInfo = { -// kdid: cdsb.kdid, -// sbbh: cdsb.sbbh, -// sbbm: cdsb.sbbm, -// itemsno: key, -// modelKey: newKey, -// xmdm, -// xmxh: key.split('~')[1], -// } -// Reflect.set(this.cdsbInfoObj, newKey, cdsbInfo) -// } -// }) -// } -// -// // 获取itemInfo表信息 -// async initItemInfo() { -// const infoParams: MA_ITEMINFOType[] = await GetSyncData('MA_ITEMINFO'); -// const carlist = this.carlist; -// const projectsObj = this.projectsObj -// infoParams.forEach((info) => { -// const key = decodeURI(info.itemsno); -// const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist).split(',') || []); -// const newKey = key.split('~').join('_') -// const xmdm = Number(key.split('~')[0]) -// const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) -// if (currentProject && (carlistArr.length == 0 || carlistArr.includes(carlist))) { -// Reflect.set(this.itemInfoObj, newKey, { -// modelKey: newKey, -// xmdm, -// xmxh: key.split('~')[1], -// }) -// } -// }) -// } -// -// // 评判相关初始化 -// async initJudge() { -// const JUDGEUI: JudgeUI = this; -// const judge = new Judge(JUDGEUI); -// // await judge.init() -// await judge.onJudgeFn(async (judgeData: JudgeCallBacData) => { -// // const { xmmcStr, carztStr, kfArr } = judgeData; -// this.xmmcStr = judgeData.xmmcStr; -// this.carztStr = judgeData.carztStr; -// this.kfArr = judgeData.kfArr; -// }); -// return judge -// } -// -// // 断点续考判断 -// async goDdxkItems() { -// const judgeConfigObj = this.judgeConfigObj -// -// const config_432: string = Reflect.get(judgeConfigObj, '432') -// //科目二强制开始断点续考 -// if (config_432 != '0' || this.examSubject == "2") { -// //断点续考判断 -// let currentParams: RouteParamsType = router.getParams() as RouteParamsType; -// const examItems: string = currentParams?.examItems; -// // 2024-01-03 16:29:26;0;20300,;2,4^2,4;null; -// if (examItems !== '' && examItems !== undefined) { -// console.info('surenjun examItems=>', JSON.stringify(examItems)) -// const examItemsArrs = examItems.split(';'); -// const startTime = examItemsArrs[0] -// const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || [] -// const ddxkKfArr = examItemsArrs[3]?.split('^').filter(item => item) || [] -// if (config_432 == '2' || this.examSubject == "2") { -// //TODO 带项目带里程 -// if (ddxkKsxmArr?.length) { -// //断点续考 -// ddxkKsxmArr.forEach(xmdm => { -// const currentProjectCenter: Project = Reflect.get(this.projectsCenterObj, xmdm) -// const projectCode = currentProjectCenter.projectCode -// const currentProject: Project = Reflect.get(this.projectsObj, projectCode) -// if (currentProject) { -// currentProject.type = '3' -// currentProject.isUpload = true -// currentProject.isEnd = true -// Reflect.set(this.projectsObj, projectCode, currentProject) -// } -// }) -// this.ddxkKsxmArr = ddxkKsxmArr -// } -// } -// //扣分续考 -// ddxkKfArr.forEach((kf) => { -// const xmdm = kf.split(',')[0] -// const kfdm = kf.split(',')[1] -// const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${xmdm}_${kfdm}`) -// const currentProject: ProjectInfo = Reflect.get(this.projectsObj, xmdm) || { name: '通用评判' } -// -// if (currentProject) { -// currentProject.type = '4' -// Reflect.set(this.projectsObj, xmdm, currentProject) -// } -// this.kfArr.push({ -// //扣分项目名称 -// xmmcStr: currentProject.name, -// desc: currentKf.markshow, -// score: currentKf.markreal, -// markcatalog: currentKf.markcatalog, -// markserial: currentKf.markserial, -// kfxh: currentKf.kfxh -// }) -// this.totalScore += currentKf.markreal * 1; -// }) -// this.ddxkKfArr = ddxkKfArr -// this.ddxkTime = Date.parse(startTime); -// this.isDdxk = true -// } -// } -// -// } -// -// // 初始化mapPoint表 -// async initMapPoint() { -// const pointParams: MA_MAP_POINTType[] = await GetSyncData('MA_MAP_POINT') -// pointParams.forEach(item => { -// -// this.mapPointArr.push({ -// point_no: Number(item.point_no), -// gps_e: Number(item.gps_e), -// gps_n: Number(item.gps_n), -// point_no_f: Number(item.point_no_f), -// point_type: Number(item.point_type), -// road_code: item.road_code, -// gps_e_Location: Number(item.gps_e_location), -// gps_n_Location: Number(item.gps_n_location), -// f_gps_e: Number(item.f_gps_e), -// f_gps_n: Number(item.f_gps_n), -// passed: Number(item.passed) -// }) -// }) -// } -// -// // 初始化mapPointItem表 -// async initMapPointItem() { -// const pointItemPoints: MA_MAP_POINT_ITEMType[] = await GetSyncData('MA_MAP_POINT_ITEM'); -// pointItemPoints.forEach(item => { -// // const { point_no, itemno, itemno1, subname } = itemPoint -// this.mapPointItemArr.push({ -// point_no: Number(item.point_no), -// itemno: Number(item.itemno), -// itemno1: Number(item.itemno1), -// subname: item.subname -// }) -// }) -// } -// -// // 初始化本地systemparam表、markrule表 -// async initTrajectoryParam(trajectoryPath: string) { -// const isTrajectoryOpen = judgeConfig.isTrajectoryOpen -// //轨迹回放读取 systemparam表、markrule表 -// const fileUtil = new FileUtils(this.context); -// const folderPath = await fileUtil.initFolder(trajectoryPath); -// const str = await fileUtil.readFile(folderPath); -// const strArr = str.split('\n'); -// const initData = strArr[0] -// const beginData = strArr[1] -// -// const initDataObj: JudgeInitObj = JSON.parse(initData) -// const beginDataObj: JudgeBeginObj = JSON.parse(beginData) -// -// const examSubject = this.carInfo.examSubject; -// this.examSubject = (isTrajectoryOpen ? (initDataObj.kskm) : examSubject) + ''; -// this.carInfo.examSubject = this.examSubject -// this.singlePlay = beginDataObj.exam == 0; -// this.carName = initDataObj.name; -// await this.initSystemParam(initDataObj.systemparm) -// await this.initMarkRules(initDataObj.mark); -// await this.initSysset(initDataObj.sysset); -// } -// -// // 上传考试里程 -// async uploadMileage() { -// if (!this.singlePlay) { -// const carInfo = this.carInfo -// -// await uploadExamMileage({ -// carId: carInfo.carId, -// examinationRoomId: carInfo.examinationRoomId, -// lsh: this.lsh, -// kskssj: this.startExamTime, -// kslc: this.jl -// }) -// } -// } -// -// build() { -// Column() { -// Row() { -// Row() { -// Image($rawfile('judge/signal_logoS.png')).width(120) -// Text(this.time).fontColor('#CCB48F').fontSize(34).padding({ left: 10, right: 5 }) -// Image($rawfile(this.isDwztRight ? 'judge/xh_green.png' : 'judge/xh_red.png')).width(50) -// }.padding({ left: 20 }) -// -// Row() { -// Text(`当前项目:${this.xmmcStr || '无'} `).fontColor('#E5CCA1').fontSize(34) -// } -// } -// .width('100%') -// .height('96') -// .backgroundColor('#001A33') -// .padding({ left: 15, right: 15 }) -// .justifyContent(FlexAlign.SpaceBetween) -// .alignItems(VerticalAlign.Center) -// -// Row() { -// Row() { -// Column() { -// Row() { -// Column() { -// Row() { -// Text('考生姓名:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) -// Text(this.name).fontColor('#FFF').fontSize(this.FONTSIZE) -// }.margin({ bottom: 10 }) -// -// Row() { -// Text('开始时间:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) -// Text(this.startTime).fontColor('#FFF').fontSize(this.FONTSIZE) -// }.margin({ bottom: 10 }) -// -// if (this.examSubject == "3") { -// Row() { -// Text('考试路线:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) -// Text(`线路${this.wayno || 3}`).fontColor('#FFAD33').fontSize(this.FONTSIZE) -// } -// } -// -// }.width('45%').alignItems(HorizontalAlign.Start) -// -// Column() { -// Row() { -// Text('身份证号:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) -// Text(this.idCard).fontColor('#FFF').fontSize(this.FONTSIZE) -// }.margin({ bottom: 10 }) -// -// Row() { -// Text('考试用时:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) -// // Text(formatTime(this.examTime)).fontColor('#FFF').fontSize(this.FONTSIZE) -// Text(dayTs(this.examTime).format("YYYY-MM-DD HH:mm:ss")).fontColor('#FFF').fontSize(this.FONTSIZE) -// }.margin({ bottom: 10 }) -// -// if (this.examSubject == "3") { -// Row() { -// if (Reflect.get(this.judgeConfigObj, '375') == '0') { -// Text(`应行驶:${this.examMileage}m`) -// .fontColor('#E5CCA1') -// .fontSize(this.FONTSIZE) -// .padding({ right: 20 }) -// } -// Text(`已行驶:${this.jl}m`).fontColor('#FFAD33').fontSize(this.FONTSIZE) -// } -// } -// -// }.alignItems(HorizontalAlign.Start) -// -// }.width('100%') -// -// Column() { -// Row() { -// Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE) -// 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) -// } -// }.height(40) -// -// Row() { -// Flex({ direction: FlexDirection.Column }) { -// if (this.kfArr.length) { -// List({ scroller: this.kfArrScroller }) { -// ForEach(this.kfArr, (item: MarkRule) => { -// ListItem() { -// Column() { -// Row() { -// Text(item.xmmcStr).fontSize(this.BIGFONTSIZE).fontColor('#FFF') -// Text(`${item.score}分`).fontSize(this.BIGFONTSIZE).fontColor('#FFF') -// } -// .width('100%') -// .backgroundColor('#38260B') -// .justifyContent(FlexAlign.SpaceBetween) -// .padding({ -// top: 12, -// bottom: 12, -// left: 8, -// right: 5 -// }) -// -// Text(item.desc + `(${item.markcatalog})`) -// .fontSize(this.BIGFONTSIZE) -// .fontColor('#E5CBA1') -// .margin({ -// top: 10, -// bottom: 8, -// left: 5, -// right: 5 -// }) -// }.margin({ top: 15 }).alignItems(HorizontalAlign.Start) -// -// }.margin({ bottom: 25 }) -// }) -// } -// .padding({ -// left: 15, -// right: 15, -// top: 30, -// bottom: 5 -// }) -// } else { -// Column() { -// Row() { -// Text('暂无扣分项').fontSize(this.BIGFONTSIZE).fontColor('#FFF') -// } -// .width('100%') -// .backgroundColor('#38260B') -// .justifyContent(FlexAlign.SpaceBetween) -// .padding({ -// top: 12, -// bottom: 12, -// left: 8, -// right: 3 -// }) -// }.margin({ top: 35 }).padding({ left: 20, right: 20 }).alignItems(HorizontalAlign.Start) -// } -// } -// .backgroundImage($rawfile('judge/score_bg.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .width(514) -// .height(618) -// .padding({ -// top: 18, -// bottom: 15, -// left: 13, -// right: 14 -// }) -// -// //科目二 -// if (this.examSubject == "2") { -// Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { -// List({}) { -// ForEach(chunkArr(this.projects, 2), (item: [ProjectInfo, ProjectInfo]) => { -// ListItem() { -// Row() { -// Row() { -// //#FF7566 #00FFD5 #E6DECF -// // Text(this.projectsObj[item[0].projectCode]) -// Text(item[0].abbreviation) -// .fontSize(item[0].abbreviation.length > 5 ? 28 : 32) -// .fontColor(this.getProjectColor(item[0])) -// } -// .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .width('48.5%') -// .height(115) -// .margin({ bottom: 5 }) -// .justifyContent(FlexAlign.Center) -// -// if (item[1]) { -// Row() { -// //#FF7566 #00FFD5 #E6DECF -// Text(item[1].abbreviation) -// .fontSize(item[1].abbreviation.length > 5 ? 28 : 32) -// .fontColor(this.getProjectColor(item[1])) -// } -// .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .width('48.5%') -// .height(115) -// .margin({ left: 5, bottom: 5 }) -// .justifyContent(FlexAlign.Center) -// } -// } -// } -// }); -// } -// } -// .backgroundImage($rawfile('judge/project_bg.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .width('57%') -// .height('100%') -// .padding(30) -// .margin({ right: 10 }) -// } -// //科目三 -// if (this.examSubject == '3') { -// Column() { -// Flex({ -// wrap: FlexWrap.Wrap, -// direction: FlexDirection.Row, -// justifyContent: FlexAlign.SpaceBetween -// }) { -// List({}) { -// ForEach(this.projects, (project: ProjectInfo) => { -// ListItem() { -// Text(project.name) { -// } -// .fontColor(this.getProjectColor(project)) -// .margin({ bottom: 2 }) -// .fontSize(24) -// }.margin({ bottom: 2 }) -// }) -// }.lanes(2).margin({ left: 25 }) -// } -// .width('100%') -// .height('57%') -// .backgroundImage($rawfile('judge/project_km3_bg.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .padding(30) -// .margin({ right: 5 }) -// -// if (this.projects.length) { -// Flex({ -// wrap: FlexWrap.Wrap, -// direction: FlexDirection.Row, -// justifyContent: FlexAlign.SpaceAround -// }) { -// List() { -// ForEach(this.artSubject3Projects, (item: string, index) => { -// ListItem() { -// } -// .backgroundImage( -// $rawfile( -// `judge/km3/${this.getIsExitManualProject(index) ? (this.getIsEndManualProject(index)) : -// (item + '_gray')}.png` -// ), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .width(174) -// .height(118 * 0.95) -// .margin({ bottom: 8 }) -// .onClick(() => { -// // this.vocObj.playAudio({ -// // type: 1, -// // name: 'button_media.wav' -// // }) -// this.setManualProjectFn(index) -// }) -// }) -// }.lanes(3).margin({ left: 5, top: 12 }) -// } -// } -// -// } -// .backgroundImage($rawfile('judge/project_bg.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .width(660) -// .height(640) -// .padding(44) -// .margin({ right: 10 }) -// } -// }.margin({ top: 15 }).height('80%').justifyContent(FlexAlign.SpaceBetween) -// }.width('100%').height('100%').alignItems(HorizontalAlign.Start).margin({ top: 10 }) -// }.height('100%').alignItems(HorizontalAlign.Start) -// }.width('75%').height('100%') -// -// Column() { -// Column() { -// Row() { -// Text(this.totalScore <= 0 ? '0' : this.totalScore + '').fontColor('#FFEECC').fontSize(55) -// Text('分').fontColor('#FFEECC').fontSize(30).padding({ top: 5 }) -// } -// .width(334) -// .height(120) -// .justifyContent(FlexAlign.Center) -// .alignItems(VerticalAlign.Center) -// .border({ width: 5, color: '#4D4136', radius: 30 }) -// .onClick(() => { -// // this.vocObj.playAudio({ -// // type: 1, -// // name: 'button_media.wav' -// // }) -// this.signDisplayComVisible = true -// }) -// -// Row() { -// Image(this.kszp).width('85%').height('85%') -// } -// .width(226) -// .height(312) -// .backgroundImage($rawfile('judge/photo_bg.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .justifyContent(FlexAlign.Center) -// .alignItems(VerticalAlign.Center) -// .margin({ top: 30, bottom: 15 }) -// } -// -// Column() { -// if (this.getIsManualKf()) { -// Row() { -// Row() { -// } -// .width(60) -// .height(60) -// .backgroundImage($rawfile('judge/manual_judge.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// -// Text('人工评判').fontColor('#FFF').fontSize(32).padding({ right: 12 }) -// } -// .width(334) -// .height(110) -// .justifyContent(FlexAlign.Center) -// .alignItems(VerticalAlign.Center) -// .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .margin({ bottom: 10 }) -// .onClick(() => { -// // this.vocObj.playAudio({ -// // type: 1, -// // name: 'button_media.wav' -// // }) -// this.isDeductedPopShow = true -// }) -// } -// -// Row() { -// Row() { -// } -// .width(60) -// .height(60) -// .backgroundImage($rawfile('judge/phone.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// -// Text('呼叫请求').fontColor('#FFF').fontSize(32).padding({ right: 12 }) -// } -// .width(334) -// .height(110) -// .justifyContent(FlexAlign.Center) -// .alignItems(VerticalAlign.Center) -// .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .margin({ bottom: 10 }) -// -// Row() { -// } -// .width(334) -// .height(100) -// .backgroundImage($rawfile('judge/anniu_nor.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '100%', height: '100%' }) -// .onClick(() => { -// // this.vocObj.playAudio({ -// // type: 1, -// // name: 'button_media.wav' -// // }) -// if (Reflect.get(this.judgeConfigObj, '353') == '0') { -// this.endPopupVisible = true -// } else { -// Prompt.showToast({ -// message: '车上不允许手动结束考试!', -// duration: 4000 -// }); -// } -// }) -// }.margin({ bottom: 30 }) -// -// } -// .width('25%') -// .height('100%') -// .justifyContent(FlexAlign.SpaceBetween) -// .alignItems(HorizontalAlign.Center) -// .margin({ bottom: 20 }) -// } -// .height('90%') -// .justifyContent(FlexAlign.Start) -// .padding({ -// top: 37, -// left: 60, -// bottom: 35, -// right: 60 -// }) -// -// -// //科目三人工扣分弹窗 -// if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj, '342') == '0') { -// DeductedPopup({ -// defaultTabIndex: this.defaultTabIndex, -// currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { -// const project: ProjectInfo = Reflect.get(this.projectsObj, projectKey) -// return project.type == '2' ? project.projectCode : undefined -// }).filter(project => project !== undefined), -// markRules: this.manualMarkRules, -// closePopup: () => { -// this.isDeductedPopShow = false; -// this.defaultTabIndex = 0; -// }, -// confirmMark: async (itemno: string, serial: string) => { -// clearTimeout(this.popTimer) -// this.popTimer = null -// this.popTimer = setTimeout(async () => { -// const judge = this.judge -// await judge.setJudgeMark(itemno, serial); -// this.isDeductedPopShow = false -// this.popTimer = null; -// }, 500) -// } -// }) -// } -// -// if (this.signDisplayComVisible) { -// Column() { -// SignDisplayCom({ -// showBack: false, -// scaleNum: 1.8, -// msgStr: this.judge.plcStr || '', -// showTrajectory: this.singlePlay ? true : (this.syssetParam623), -// }).margin({ top: 100 }) -// -// Row() { -// } -// .width(240) -// .height(240) -// .position({ x: '81%', y: 80 }) -// .backgroundImage($rawfile('judge/close.png'), ImageRepeat.NoRepeat) -// .backgroundImageSize({ width: '33.33%', height: '33.33%' }) -// .onClick(() => { -// // this.vocObj.playAudio({ -// // type: 1, -// // name: 'button_media.wav' -// // }) -// this.signDisplayComVisible = false -// }) -// }.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.6)') -// } -// -// //科目三人工项目确认框 -// if (this.isAmplifyPopShow && this.examSubject == '3') { -// AmplifyPopup({ -// amplifyImgIndex: this.amplifiedImgIndex, -// confirmAmplify: async (amplify: AmplifyItem) => { -// clearTimeout(this.popTimer) -// this.popTimer = null -// this.popTimer = setTimeout(async () => { -// const judge = this.judge -// await judge.setJudgeItem(amplify.projectCode, 1); -// this.isAmplifyPopShow = false -// this.popTimer = null; -// }, 500) -// }, -// closeAmplifyPop: () => { -// this.isAmplifyPopShow = false -// } -// }) -// } -// -// //结束考试弹窗 -// if (this.endPopupVisible) { -// EndPoPup({ -// title: '确定结束考试吗?', -// cancelFn: () => { -// this.endPopupVisible = false; -// }, -// confirmFn: async () => { -// if (this.isErrorMsgEnd) { -// this.judge.closeAllFiles() -// router.back() -// return -// } -// if (Reflect.get(this.judgeConfigObj, '344') == 1) { -// Prompt.showToast({ -// message: '考试未结束,不允许手动退出!', -// duration: 4000 -// }); -// return -// } -// this.endPopupVisible = false; -// this.loadingPopupVisible = true -// clearInterval(this.timer); -// clearInterval(AppStorage.get('judgeTimer')) -// try { -// this.judge.checkExamIsEnd(true); -// } catch (e) { -// this.judge.closeAllFiles() -// router.back() -// } -// -// } -// }) -// } -// -// //loading 弹窗 -// if (this.loadingPopupVisible) { -// LoadingPopup({ -// title: '正在生成考试记录,请稍后...', -// }) -// } -// -// if (this.errorMsg) { -// MsgPopup({ -// title: this.errorMsg, -// confirmFn: () => { -// this.errorMsg = '' -// this.isErrorMsgEnd = true; -// if (this.disConnectErrorOpen) { -// this.context.terminateSelf() -// } else { -// router.back() -// } -// }, -// }) -// } -// -// if (this.dwztErrorVisible) { -// DwztErrorPopup({ -// title: '当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框', -// cancelFn: () => { -// this.dwztErrorVisible = false; -// }, -// confirmFn: () => { -// clearInterval(this.timer); -// clearInterval(AppStorage.get('judgeTimer')) -// this.judge.checkExamIsEnd(true); -// }, -// }) -// } -// -// if (this.disConnectErrorOpen) { -// -// } -// } -// .height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) -// } -// -// getProjectColor(project: ProjectInfo) { -// const type = project.type; -// switch (type) { -// case '1': -// return '#E6DECF'; -// break; -// case '2': -// return '#FFAD33'; -// break; -// case '3': -// return '#ff109d0a'; -// break; -// case '4': -// return '#FF7566'; -// break; -// default: -// return '#E6DECF'; -// break; -// } -// } -// -// //人工项目操作 -// async setManualProjectFn(index: number) { -// -// const judgeConfigObj = this.judgeConfigObj; -// const isManualProjectIn = this.isManualProjectIn; -// const getIsExitManualProject = this.getIsExitManualProject; -// const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr; -// const projectsObj = this.projectsObj; -// -// const projectCode = Reflect.get(artSubject3ProjectsCodesArr, index) -// if (index === 5) { -// console.info('surenjun 靠边停车状态=> ', getIsExitManualProject(index)) -// } -// const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode) -// if (getIsExitManualProject(index)) { -// // 正在进行的项目 取消项目 -// if (isManualProjectIn && currentProject.type == '2') { -// //判断人工是否能取消项目 && 当前项目有扣分的不能取消 -// if (Reflect.get(this.judgeConfigObj, '340') == 1) { -// await this.judge.setJudgeItem(projectCode, 2); -// Prompt.showToast({ -// message: '项目取消', -// duration: 2000 -// }) -// return -// } -// } -// -// // 靠边停车时候可以触发 -// if (Reflect.get(this.judgeConfigObj, '343') === '0') { -// const xmmcStr = this.xmmcStr; -// if (xmmcStr == '无' || xmmcStr == '') { -// //512[6] 人工项目按钮放大确认 -// const param512: string[] = (Reflect.get(this.judgeConfigObj, '512') || '').split(','); -// console.info('surenjun', param512) -// if (param512[6] !== '0') { -// this.amplifiedImgIndex = index; -// this.isAmplifyPopShow = true -// } else { -// const judge = this.judge -// await judge.setJudgeItem(projectCode, 1); -// } -// } else { -// if (index === 5) { -// Prompt.showToast({ -// message: `${xmmcStr}未结束,不允许靠边停车`, -// duration: 8000 -// }); -// } -// } -// } else { -// this.amplifiedImgIndex = index; -// this.isAmplifyPopShow = true -// } -// } -// } -// -// // 获取是否能人工进项目 -// getIsExitManualProject = (index: number) => { -// -// const judgeConfigObj = this.judgeConfigObj; -// const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr; -// const projectsObj = this.projectsObj; -// const carztStr = this.carztStr; -// const isManualProjectIn = this.isManualProjectIn; -// const isProjectIn = this.isProjectIn; -// const getProjectIsInRoad = this.getProjectIsInRoad; -// -// const projectCode = artSubject3ProjectsCodesArr[index]; -// const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode) -// if (currentProject === undefined) { -// return false -// } -// const projectType = currentProject.type; -// -// //不允许人工触发的项目列表,以","分隔 -// const unExitManualProjects: string[] = Reflect.get(this.judgeConfigObj, '332').split(',') || []; -// //直线行驶中不进其他考试项目(0-否 1-是) -// const param348: string = Reflect.get(this.judgeConfigObj, '348') || '0', -// //里程不够允许手工点靠边停车(0-否 1-是) -// param387: string = Reflect.get(this.judgeConfigObj, '387') || '0', -// //里程不够不报靠边停车(0-否+1-是+2-必考项目未完成且里程不够不报项目) -// param319: string = Reflect.get(this.judgeConfigObj, '319') || '0', -// //人工项目是否能取消 1:可取消; -// param340: string = Reflect.get(this.judgeConfigObj, '340') || '0', -// //307参数里设置的项目,项目已经做过,后续不能人工触发; -// param307: string[] = (Reflect.get(this.judgeConfigObj, '307') || '').split(','); -// -// //非行驶状态(没有速度),人工项目不能触发(按钮灰色) -// if (carztStr === '停车') { -// return false -// } -// -// //车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能) -// if (Reflect.get(this.judgeConfigObj, '342') === '3' || Reflect.get(this.judgeConfigObj, '342') === '2') { -// return false -// } -// -// //不允许人工触发的项目列表 -// if (unExitManualProjects.includes(artSubject3ProjectsCodesArr[index])) { -// return false -// } -// -// //项目进行中不能人工触发 -// if (isProjectIn) { -// if (param340 == '1') { -// if (isManualProjectIn && (currentProject.type == '2')) { -// return true -// } else { -// return false -// } -// } -// return false -// } -// -// //项目路段信息判断 -// if (!getProjectIsInRoad(projectCode + '')) { -// return false -// } -// -// const project_9: ProjectInfo = Reflect.get(projectsObj, '9') -// // 直线行驶中不进其他考试项目(0-否 1-是) -// if (param348 == '0' && project_9.type == '2') { -// return index === 0 ? true : false -// } -// -// //项目已经做过,后续不能人工触发 -// if (param307.includes(projectCode) && (projectType == '3' || projectType == '4')) { -// return false -// } -// -// //319不为0,或者387不为1,里程不够时,靠边停车项目不能触发 -// if ((param387 != '1' || param319 != '0') && index === 5) { -// const examMileage = this.examMileage -// const isRequiredProjectsEnd = this.isRequiredProjectsEnd -// const jl = this.jl -// //里程是否达标 && 必考项目是否全完成 -// return jl >= Number(examMileage) && isRequiredProjectsEnd -// } -// return true -// } -// // 判断项目是否在当前路段号 -// getProjectIsInRoad = (projectCode: string,) => { -// const judgeConfigObj = this.judgeConfigObj; -// const lane = this.lane; -// const road = lane.road; -// const num = lane.num; -// const count = lane.count; -// -// 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 = { -// //直线行驶 -// param_3, -// //变更车道 -// param_4, -// //超车 -// param_10, -// //靠边停车 -// param_11, -// //会车 -// param_9, -// //掉头 -// param_12, -// }; -// -// -// //未测绘得道路上或者不在差分状态 -// if (road === '') { -// return false -// } -// const currentProjectRoad: string[] = Reflect.get(projectRoads, `param_${projectCode}`) -// if (currentProjectRoad.length == 0) { -// return true -// } -// -// //设置了514-519参数,只能在设置的路段触发对应项目 -// if (currentProjectRoad.includes(road)) { -// //如果525为1,则514-519设置的路段不能触发对应项目 -// if (Reflect.get(this.judgeConfigObj, '525') == '1') { -// return false -// } -// } else { -// return false -// } -// -// //405参数为2是,如果在最左侧车道,超车项目不能触发; -// if (projectCode == '10' && -// Reflect.get(this.judgeConfigObj, '405') == '2' && -// (num === count) && -// num > 0 -// ) { -// return false -// } -// -// // 车道总数少于2条,超车和变道不能触发 -// if (projectCode == '10' || projectCode == '4') { -// if (count < 2) { -// return false -// } -// } -// return true -// -// } -// // 获取人工项目是否已做 -// getIsEndManualProject = (index: number) => { -// const projectName = this.artSubject3Projects[index]; -// const projectCode = this.artSubject3ProjectsCodesArr[index]; -// const currentProject: ProjectInfo = Reflect.get(this.projectsObj, projectCode) -// const type = currentProject.type -// if (type == '2') { -// return projectName -// } -// return (type == '3' || type == '4') ? `${projectName}_red` : `${projectName}_green`; -// } -// // 获取是否能进行人工评判 -// getIsManualKf = () => { -// if (this.examSubject == '3') { -// //杭州训练模式不允许人工评判 -// if (this.singlePlay && Reflect.get(this.judgeConfigObj, '211') == 'zjhz') { -// return false -// } -// if (Reflect.get(this.judgeConfigObj, '342') == '0') { -// return true -// } -// } else { -// return false -// } -// } -// } -// -// export const JudgePage = Index +import router from '@ohos.router'; +import Prompt from '@system.prompt'; +import common from '@ohos.app.ability.common'; +import EndPoPup from './compontents/judge/EndPopup'; +import LoadingPopup from './compontents/judge/LoadingPopup'; +import DeductedPopup from './compontents/judge/DeductionPopup'; +import AmplifyPopup from './compontents/judge/AmplifyPopup'; +import Judge from './judgeSDK/judge'; +import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon'; +import { uploadExamMileage } from '../api/judge'; +import DwztErrorPopup from './compontents/judge/DwztErrorPopup'; +import MsgPopup from './compontents/judge/MsgPopup'; +import { + CARINFO, + CDSBInfo, + LANE, + MAPITEMPOINTITEM, + MAPPOINT, + MarkRule, + Project, SYSTEMPARMARR +} from './judgeSDK/api/judgeSDK.d'; + +import { JudgeConfig } from './judgeSDK/utils/judgeConfig'; + +import SignDisplayCom from './compontents/signDisplayCom'; +import { + AmplifyItem, + CarInfoType, + CDSBInfos, DefaultJudgeConfigObj, + ES_CARINFOType, + ItemInfos, + JudgeBeginObj, + JudgeCallBacData, + JudgeInitObj, + JudgeUI, MA_CDSBINFOType, + MA_ITEMINFOType, + MA_MAP_POINT_ITEMType, + MA_MAP_POINTType, MA_SYSTEMPARMType, + MarkRules, + MASYSSETTableType, ProjectInfo, + ProjectInfos, + ProjectRoads, + RouteParamsType, + SYSSET, + SyssetConfig, User +} from '../model'; +import { GetSyncData } from '../utils/table/Operation'; +import dayTs from '../utils/Date'; +import { GetCurrentTime } from '../utils/Common'; +import { chunkArr } from './judgeSDK/utils/Common'; +import FileUtils from '../utils/FileUtils'; + + +@Entry +@Component +struct Index { + scroller: Scroller = new Scroller() + //页面通用字体大小 + @State wayno: number = 0 + @State FONTSIZE: number = 30 + @State BIGFONTSIZE: number = 32 + //结束考试弹窗 + @State endPopupVisible: boolean = false + //等待弹窗(考试及格,考试不及格使用) + @State loadingPopupVisible: boolean = false + //实时轨迹弹窗 + @State signDisplayComVisible: boolean = false + @State isDdxk: boolean = false; + @State time: string = '' + //考试用时 + @State examTime: number = 0 + //开始时间 + @State startTime: string = '00:00:00' + @State startFullTime: string = '' + @State startHourTime: string = '' + @State startExamTime: string = '' + //科目类型 + @State examSubject: string = '3'; + @State ddxkTime: number = 0; + @State ddxkKsxmArr: string[] = [] + @State ddxkKfArr: string[] = [] + @State xmmcStr: string = '' + @State carztStr: string = '' + @State kfArr: MarkRule[] = [] + @State name: string = '' + @State idCard: string = '' + @State singlePlay: boolean = false; + @State totalScore: number = 100 + //模拟考试项目 + @State projects: ProjectInfo[] = [] + @State projectsObj: ProjectInfos = {} + @State projectsCenterObj: ProjectInfos = {} + @State markRuleListObj: MarkRules = {} + @State cdsbInfoObj?: CDSBInfos = {} + @State itemInfoObj?: ItemInfos = {} + @State timer: number = 0 + @State judgeConfig: SyssetConfig[] = [] + @State judgeConfigObj: DefaultJudgeConfigObj = defaultJudgeConfigObj + //流水号 + @State lsh: string = '' + @State kszp: string = '' + @State ksdd: string = '' + @State kssycs: string = '' + @State ksxl: string = '' + @State kslx: string = '' + //监管线路代码 + @State xldm: string = '' + //监管接口序列号 + @State serialNumber: string = '' + @State syssetParam623: boolean = false; + @State syssetParam211: string = ''; + @State carType: string = '' + @State carName: string = '' + @State isDeductedPopShow: boolean = false + @State isAmplifyPopShow: boolean = false + @State amplifiedImgIndex: number = 0 + judge: Judge + //行驶距离 + @State jl: number = 0 + //应考里程 + @State examMileage: string = '0' + @State artSubject3Projects: string[] = ['直线', '会车', '变道', '超车', '掉头', '停车'] + @State artSubject3ProjectsCodesArr: string[] = ['3', '9', '4', '10', '12', '11'] + @State manualMarkRules: MarkRule[] = [] + //科目三评判初始化数据 + @State systemparmArr: SYSTEMPARMARR[] = [] + @State mapPointItemArr: MAPITEMPOINTITEM[] = [] + @State carinfoArr: CARINFO[] = [] + @State mapPointArr: MAPPOINT[] = [] + //手动项目是否在进行中 + @State isManualProjectIn: boolean = false; + //项目是否进行中 + @State isProjectIn: boolean = false; + //正在进行的项目代码 + @State currentXmdm?: number = 0 + // 必考项目除靠边停车是否全部完成 + @State isRequiredProjectsEnd: boolean = false; + @State isAllProjectsEnd: boolean = false; + @State draw: boolean = false; + @State lane: LANE = { road: '', num: 0, count: 0 } + //定位差分状态时候正常 + @State isDwztRight: boolean = true; + @State defaultTabIndex: number = 0; + public kfArrScroller: Scroller = new Scroller() + //档位 + @State dw: string = '' + //速度 + @State sd: string = '' + @State mileageTimer: number = 0; + @State passingScore: number = 80 + @State dwztErrorVisible: boolean = false; + @State popTimer: number = 0; + @State carlist: string = '' + @State errorMsg: string = '' + @State carInfo: CarInfoType = {} + @State isErrorMsgEnd: boolean = false + @State disConnectErrorOpen: boolean = false + public context = getContext(this) as common.UIAbilityContext; + + async aboutToDisappear() { + clearInterval(this.mileageTimer) + } + + async aboutToAppear() { + const time = GetCurrentTime() + this.carInfo = AppStorage.get('carInfo') + this.singlePlay = AppStorage.get('singlePlay') + this.startTime = time.split(' ')[1] + this.startFullTime = GetCurrentTime(1); + // this.startHourTime = await getCurrentHourTime() + this.startTime = dayTs().format("HHmmssSSS") + this.startExamTime = time + setInterval(async () => { + this.time = GetCurrentTime(); + this.examTime += 1; + }, 1000); + //初始化数据库表 + await this.initDb() + //断点续考 + await this.goDdxkItems() + //初始化评判 + const judge = await this.initJudge(); + this.judge = judge + } + + //初始化相关数据库表 + async initDb() { + this.examSubject = this.carInfo.examSubject; + // const { isTrajectoryOpen, trajectoryPath } = judgeConfig + await this.initStudent(); + await this.initCar(); + + //是否开启轨迹回放模式 + if (JudgeConfig.isTrajectoryOpen) { + this.initTrajectoryParam(JudgeConfig.trajectoryPath) + } else { + await this.initSystemParam() + await this.initMarkRules(); + await this.initSysset(); + } + await this.initCDSBInfo() + await this.initItemInfo() + + // 科目三新增读取表数据 + if (this.examSubject == '3') { + await this.initMapPoint() + await this.initMapPointItem() + //定时上传考试里程 + // let mileageTimer = setInterval(()=>{ + // this.uploadMileage() + // },5000) + // this.mileageTimer = mileageTimer + } + } + + // 查询考车信息 + async initCar() { + // const result = await getSyncData('ES_CARINFO') + const result = await GetSyncData("ES_CARINFO") + const carInfo = result[0] || {}; + this.carName = decodeURI(carInfo.carclass) + this.carType = carInfo.kscx + this.carinfoArr.push({ + CARID: carInfo.carid, + IPADDR: '', + CARCLASS: decodeURI(carInfo.carclass), + KSCX: carInfo.kscx, + // CARNAME: decodeURI(carInfo.carname), + CARNAME: "", + FLAG: carInfo.flag, + BK1: carInfo.bk1, + BK2: carInfo.bk2, + }) + console.info('surenjun =>carinfoArrr', JSON.stringify(this.carinfoArr)) + } + + // 获取考生信息 + async initStudent() { + const students = await GetSyncData('USER') + const stuInfo = students[0]; + this.name = stuInfo.xm || '测试考生'; + this.idCard = stuInfo.sfzmhm || '01234567891010'; + this.lsh = this.singlePlay ? '0000000000000' : stuInfo.lsh; + this.kszp = stuInfo.kszp; + this.ksdd = stuInfo.ksdd; + this.kssycs = stuInfo.kssycs; + this.ksxl = stuInfo.ksxl; + this.wayno = Number(stuInfo.ksxl); + this.xldm = stuInfo.xldm; + this.kslx = stuInfo.kslx; + } + + // 获取扣分代码信息 + async initMarkRules(markRules ?: MarkRule[]) { + const markRuleParams = markRules || await GetSyncData('MA_MARKRULE') + + markRuleParams.forEach(mark => { + const tempObj: MarkRule = { + itemno: mark.itemno * 1, + markcatalog: mark.markcatalog, + markshow: decodeURI(mark.markshow), + markreal: mark.markreal * 1, + markserial: mark.markserial, + kfxh: mark.kfxh, + OnlyOneKind: mark.onlyoneid * 1, + NoCancelId: mark.nocancelid * 1, + GPS_SID: mark.gps_sid == 0 ? false : true + } + + //筛选出人工评判的扣分 + if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) { + this.manualMarkRules.push(tempObj) + } + tempObj.markserial = mark.markserial + Reflect.set(this.markRuleListObj, `${mark.itemno}_${mark.markserial}`, tempObj) + }) + } + + // 考试项目是否全部完成 + + // 获取sysset表信息 + async initSysset(sysset?: SYSSET[]) { + const syssetParams: SYSSET[] | MASYSSETTableType[] = sysset || await GetSyncData('MA_SYSSET') + const serialNumberArr = (syssetParams as SYSSET[]).filter(sys => sys.v_no === '901'); + console.info('surenjun serialNumberArr' + JSON.stringify(serialNumberArr)) + this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || ''; + // const { isTrajectoryOpen } = judgeConfig + const syssetJudgeConfigArr: SyssetConfig[] = [] + + syssetParams.forEach((sys: SYSSET) => { + if (JudgeConfig.isTrajectoryOpen) { + sys.v_no = String(sys.key); + sys.v_name = sys.name; + sys.v_value = sys.value + } + + // const { v_no, v_value } = sys; + const v_no_num = Number(sys.v_no) + const value = decodeURIComponent(sys.v_value) + if (v_no_num >= 10 && v_no_num <= 900) { + const name = + syssetJudgeConfigArr.push({ + key: v_no_num, value: value, + name: decodeURI(sys.v_name) + }) + } + + //623 考试中是否可以查看轨迹画面(0-否+1-是) + if (sys.v_no == '623') { + this.syssetParam623 = value == '1' ? true : false + } + + //科目三应行驶距离参数 + if (sys.v_no == '303') { + this.examMileage = this.examMileage == '0' ? (sys.v_value + '') : this.examMileage; + } + + // //地点版本参数 + // if (sys.v_no == '211') { + // this.syssetParam211 = decodeURIComponent(sys.v_value + '') + // } + + //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) + if (sys.v_no == '364' && sys.v_value == "2") { + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + // const { sczb, kfdm } = currentParams; + const kfdm = currentParams.kfdm; + currentParams.kfdm.forEach(kf => { + // const { xmdm, kfdm } = kf + + const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${kf.xmdm}_${kf.kfdm}`) + const currentProject: ProjectInfo = Reflect.get(this.projectsObj, kf.xmdm) + + // 过滤考前绕车一周上车准备的扣分 + if (currentParams.sczb == "1" && kf.xmdm == 1) { + return + } + + this.kfArr.push({ + //扣分项目名称 + xmmcStr: currentProject.name, + xmdm: kf.xmdm, + desc: currentKf.markshow, + score: currentKf.markreal, + markcatalog: currentKf.markcatalog, + markserial: currentKf.markserial, + kfxh: currentKf.kfxh + }) + this.totalScore += currentKf.markreal * 1; + }) + const project_1 = Reflect.get(this.projectsObj, 1) + project_1.type = kfdm.length ? '4' : '3'; + Reflect.set(this.projectsObj, 1, project_1) + + } + Reflect.set(this.judgeConfigObj, sys.v_no, value) + }); + this.judgeConfig = syssetJudgeConfigArr; + } + + //初始化systemParam表 + async initSystemParam(sysParam?: MA_SYSTEMPARMType[]) { + let systemParms: MA_SYSTEMPARMType[] = sysParam || await GetSyncData('MA_SYSTEMPARM') + + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + // const { carName, carType, examSubject } = this; + //小车车型列表 + const sCarTypes = ['C1', 'C2', 'C5'] + if (this.singlePlay) { + this.wayno = Number(currentParams.wayno) || 1; + } + //真实监管下发的项目 + let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item); + console.info('surenjun kStringArr', JSON.stringify(kStringArr)) + let isInExam = kStringArr.length > 0; + // const { isTrajectoryOpen } = judgeConfig + let carNo = '', allItems: string[] = []; + systemParms.forEach((systemParm) => { + if (JudgeConfig.isTrajectoryOpen) { + systemParm.no1 = systemParm.NO1 + ''; + systemParm.no2 = systemParm.NO2 + ''; + systemParm.no3 = systemParm.NO3 + ''; + systemParm.txt1 = systemParm.TXT1; + systemParm.txt2 = systemParm.TXT2; + systemParm.txt3 = systemParm.TXT3; + } + // const { no1, no2, no3, } = systemParm; + const txt1 = decodeURI(systemParm.txt1) + const txt2 = decodeURI(systemParm.txt2) + + const no1 = systemParm.no1; + const no2 = systemParm.no2; + const no3 = systemParm.no3; + + //获取当前考车的no2 + if (systemParm.no1 == "3" && systemParm.no3 == "1") { + if (txt1 === this.carName) { + carNo = systemParm.no2 + this.carlist = carNo + } + } + + //获取及格分数线 + if (systemParm.no1 == "3" && systemParm.no3 == "3" && carNo === systemParm.no2) { + this.passingScore = Number(txt1) || 0; + } + //根据车型获取应行驶里程数 + if (systemParm.no1 == "3" && systemParm.no3 == "15" && carNo === systemParm.no2) { + this.examMileage = ((decodeURI(systemParm.txt1)) || '').split('^')[0]; + } + //获取当前考车的考试项目 + if (carNo !== '' && systemParm.no1 == "3" && systemParm.no2 == carNo && systemParm.no3 == "10") { + allItems = decodeURIComponent(systemParm.txt1).split(',').filter(txt => txt !== '') + console.info('surenjun', JSON.stringify(allItems)) + } + if ( + //科目二获取项目 + (this.examSubject == "2" && allItems.length && systemParm.no1 == '6' && allItems.includes(systemParm.no2)) + || + //科目三获取项目 + (this.examSubject == "3" && systemParm.no1 == "6") + ) { + const name = decodeURI(systemParm.txt1) + //小车过滤掉 夜间模拟行驶 + if (sCarTypes.includes(this.carType) && name === '夜间行驶') { + return + } + const currentProject: ProjectInfo = { + name, + abbreviation: decodeURI(systemParm.txt3), + projectCode: no2, + projectCodeCenter: txt2, + //是否是必考 加减档设置成非必考 + isRequired: no2 == '14' ? false : allItems.includes(no2 + ''), + //是否考过了 + isEnd: false, + //项目开始数据是否上传过 + isUpload: false, + } + const no2Num = Number(systemParm.no2) + //真实监管下发考试项目 + if (isInExam && !(kStringArr.includes(txt2) || kStringArr.includes(no2 + ''))) { + console.info('surenjun =>', txt2) + console.info('surenjun => no2', systemParm.no2) + currentProject.type = '3' + currentProject.isUpload = true + currentProject.isEnd = true + this.ddxkKsxmArr.push(txt2) + } + Reflect.set(this.projectsObj, no2Num, currentProject) + Reflect.set(this.projectsCenterObj, txt2, currentProject) + this.projects.push(currentProject); + } + + this.systemparmArr.push({ + 'NO1': Number(systemParm.no1), + 'NO2': Number(systemParm.no2), + 'NO3': Number(systemParm.no3), + 'TXT1': decodeURIComponent(systemParm.txt1), + 'TXT2': decodeURIComponent(systemParm.txt2), + 'TXT3': decodeURIComponent(systemParm.txt3), + }) + }) + const projects = this.projects; + console.info('surenjun', JSON.stringify(this.ddxkKsxmArr)) + + if (!projects.length) { + Prompt.showToast({ + message: '读取数据库信息失败,请重新联网更新!', + duration: 8000 + }); + router.back(); + } + } + + // 获取场地设备信息 + async initCDSBInfo() { + const cdsbParams: MA_CDSBINFOType[] = await GetSyncData('MA_CDSBINFO') + //只记录考试项目的模型 + const projectsObj = this.projectsObj + cdsbParams.forEach((cdsb) => { + const key = decodeURI(cdsb.itemsno) + const newKey = key.split('~').join('_') + const xmdm = Number(key.split('~')[0]) + const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) + if (currentProject) { + const cdsbInfo: CDSBInfo = { + kdid: cdsb.kdid, + sbbh: cdsb.sbbh, + sbbm: cdsb.sbbm, + itemsno: key, + modelKey: newKey, + xmdm, + xmxh: key.split('~')[1], + } + Reflect.set(this.cdsbInfoObj, newKey, cdsbInfo) + } + }) + } + + // 获取itemInfo表信息 + async initItemInfo() { + const infoParams: MA_ITEMINFOType[] = await GetSyncData('MA_ITEMINFO'); + const carlist = this.carlist; + const projectsObj = this.projectsObj + infoParams.forEach((info) => { + const key = decodeURI(info.itemsno); + const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist).split(',') || []); + const newKey = key.split('~').join('_') + const xmdm = Number(key.split('~')[0]) + const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) + if (currentProject && (carlistArr.length == 0 || carlistArr.includes(carlist))) { + Reflect.set(this.itemInfoObj, newKey, { + modelKey: newKey, + xmdm, + xmxh: key.split('~')[1], + }) + } + }) + } + + // 评判相关初始化 + async initJudge() { + const JUDGEUI: JudgeUI = this; + const judge = new Judge(JUDGEUI); + // await judge.init() + await judge.onJudgeFn(async (judgeData: JudgeCallBacData) => { + // const { xmmcStr, carztStr, kfArr } = judgeData; + this.xmmcStr = judgeData.xmmcStr; + this.carztStr = judgeData.carztStr; + this.kfArr = judgeData.kfArr; + }); + return judge + } + + // 断点续考判断 + async goDdxkItems() { + const judgeConfigObj = this.judgeConfigObj + + const config_432: string = Reflect.get(judgeConfigObj, '432') + //科目二强制开始断点续考 + if (config_432 != '0' || this.examSubject == "2") { + //断点续考判断 + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + const examItems: string = currentParams?.examItems; + // 2024-01-03 16:29:26;0;20300,;2,4^2,4;null; + if (examItems !== '' && examItems !== undefined) { + console.info('surenjun examItems=>', JSON.stringify(examItems)) + const examItemsArrs = examItems.split(';'); + const startTime = examItemsArrs[0] + const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || [] + const ddxkKfArr = examItemsArrs[3]?.split('^').filter(item => item) || [] + if (config_432 == '2' || this.examSubject == "2") { + //TODO 带项目带里程 + if (ddxkKsxmArr?.length) { + //断点续考 + ddxkKsxmArr.forEach(xmdm => { + const currentProjectCenter: Project = Reflect.get(this.projectsCenterObj, xmdm) + const projectCode = currentProjectCenter.projectCode + const currentProject: Project = Reflect.get(this.projectsObj, projectCode) + if (currentProject) { + currentProject.type = '3' + currentProject.isUpload = true + currentProject.isEnd = true + Reflect.set(this.projectsObj, projectCode, currentProject) + } + }) + this.ddxkKsxmArr = ddxkKsxmArr + } + } + //扣分续考 + ddxkKfArr.forEach((kf) => { + const xmdm = kf.split(',')[0] + const kfdm = kf.split(',')[1] + const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${xmdm}_${kfdm}`) + const currentProject: ProjectInfo = Reflect.get(this.projectsObj, xmdm) || { name: '通用评判' } + + if (currentProject) { + currentProject.type = '4' + Reflect.set(this.projectsObj, xmdm, currentProject) + } + this.kfArr.push({ + //扣分项目名称 + xmmcStr: currentProject.name, + desc: currentKf.markshow, + score: currentKf.markreal, + markcatalog: currentKf.markcatalog, + markserial: currentKf.markserial, + kfxh: currentKf.kfxh + }) + this.totalScore += currentKf.markreal * 1; + }) + this.ddxkKfArr = ddxkKfArr + this.ddxkTime = Date.parse(startTime); + this.isDdxk = true + } + } + + } + + // 初始化mapPoint表 + async initMapPoint() { + const pointParams: MA_MAP_POINTType[] = await GetSyncData('MA_MAP_POINT') + pointParams.forEach(item => { + + this.mapPointArr.push({ + point_no: Number(item.point_no), + gps_e: Number(item.gps_e), + gps_n: Number(item.gps_n), + point_no_f: Number(item.point_no_f), + point_type: Number(item.point_type), + road_code: item.road_code, + gps_e_Location: Number(item.gps_e_location), + gps_n_Location: Number(item.gps_n_location), + f_gps_e: Number(item.f_gps_e), + f_gps_n: Number(item.f_gps_n), + passed: Number(item.passed) + }) + }) + } + + // 初始化mapPointItem表 + async initMapPointItem() { + const pointItemPoints: MA_MAP_POINT_ITEMType[] = await GetSyncData('MA_MAP_POINT_ITEM'); + pointItemPoints.forEach(item => { + // const { point_no, itemno, itemno1, subname } = itemPoint + this.mapPointItemArr.push({ + point_no: Number(item.point_no), + itemno: Number(item.itemno), + itemno1: Number(item.itemno1), + subname: item.subname + }) + }) + } + + // 初始化本地systemparam表、markrule表 + async initTrajectoryParam(trajectoryPath: string) { + const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen + //轨迹回放读取 systemparam表、markrule表 + const fileUtil = new FileUtils(this.context); + const folderPath = await fileUtil.initFolder(trajectoryPath); + const str = await fileUtil.readFile(folderPath); + const strArr = str.split('\n'); + const initData = strArr[0] + const beginData = strArr[1] + + const initDataObj: JudgeInitObj = JSON.parse(initData) + const beginDataObj: JudgeBeginObj = JSON.parse(beginData) + + const examSubject = this.carInfo.examSubject; + this.examSubject = (isTrajectoryOpen ? (initDataObj.kskm) : examSubject) + ''; + this.carInfo.examSubject = this.examSubject + this.singlePlay = beginDataObj.exam == 0; + this.carName = initDataObj.name; + await this.initSystemParam(initDataObj.systemparm) + await this.initMarkRules(initDataObj.mark); + await this.initSysset(initDataObj.sysset); + } + + // 上传考试里程 + async uploadMileage() { + if (!this.singlePlay) { + const carInfo = this.carInfo + + await uploadExamMileage({ + carId: carInfo.carId, + examinationRoomId: carInfo.examinationRoomId, + lsh: this.lsh, + kskssj: this.startExamTime, + kslc: this.jl + }) + } + } + + build() { + Column() { + Row() { + Row() { + Image($rawfile('judge/signal_logoS.png')).width(120) + Text(this.time).fontColor('#CCB48F').fontSize(34).padding({ left: 10, right: 5 }) + Image($rawfile(this.isDwztRight ? 'judge/xh_green.png' : 'judge/xh_red.png')).width(50) + }.padding({ left: 20 }) + + Row() { + Text(`当前项目:${this.xmmcStr || '无'} `).fontColor('#E5CCA1').fontSize(34) + } + } + .width('100%') + .height('96') + .backgroundColor('#001A33') + .padding({ left: 15, right: 15 }) + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(VerticalAlign.Center) + + Row() { + Row() { + Column() { + Row() { + Column() { + Row() { + Text('考生姓名:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) + Text(this.name).fontColor('#FFF').fontSize(this.FONTSIZE) + }.margin({ bottom: 10 }) + + Row() { + Text('开始时间:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) + Text(this.startTime).fontColor('#FFF').fontSize(this.FONTSIZE) + }.margin({ bottom: 10 }) + + if (this.examSubject == "3") { + Row() { + Text('考试路线:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) + Text(`线路${this.wayno || 3}`).fontColor('#FFAD33').fontSize(this.FONTSIZE) + } + } + + }.width('45%').alignItems(HorizontalAlign.Start) + + Column() { + Row() { + Text('身份证号:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) + Text(this.idCard).fontColor('#FFF').fontSize(this.FONTSIZE) + }.margin({ bottom: 10 }) + + Row() { + Text('考试用时:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) + // Text(formatTime(this.examTime)).fontColor('#FFF').fontSize(this.FONTSIZE) + Text(dayTs(this.examTime).format("YYYY-MM-DD HH:mm:ss")).fontColor('#FFF').fontSize(this.FONTSIZE) + }.margin({ bottom: 10 }) + + if (this.examSubject == "3") { + Row() { + if (Reflect.get(this.judgeConfigObj, '375') == '0') { + Text(`应行驶:${this.examMileage}m`) + .fontColor('#E5CCA1') + .fontSize(this.FONTSIZE) + .padding({ right: 20 }) + } + Text(`已行驶:${this.jl}m`).fontColor('#FFAD33').fontSize(this.FONTSIZE) + } + } + + }.alignItems(HorizontalAlign.Start) + + }.width('100%') + + Column() { + Row() { + Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE) + 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) + } + }.height(40) + + Row() { + Flex({ direction: FlexDirection.Column }) { + if (this.kfArr.length) { + List({ scroller: this.kfArrScroller }) { + ForEach(this.kfArr, (item: MarkRule) => { + ListItem() { + Column() { + Row() { + Text(item.xmmcStr).fontSize(this.BIGFONTSIZE).fontColor('#FFF') + Text(`${item.score}分`).fontSize(this.BIGFONTSIZE).fontColor('#FFF') + } + .width('100%') + .backgroundColor('#38260B') + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + top: 12, + bottom: 12, + left: 8, + right: 5 + }) + + Text(item.desc + `(${item.markcatalog})`) + .fontSize(this.BIGFONTSIZE) + .fontColor('#E5CBA1') + .margin({ + top: 10, + bottom: 8, + left: 5, + right: 5 + }) + }.margin({ top: 15 }).alignItems(HorizontalAlign.Start) + + }.margin({ bottom: 25 }) + }) + } + .padding({ + left: 15, + right: 15, + top: 30, + bottom: 5 + }) + } else { + Column() { + Row() { + Text('暂无扣分项').fontSize(this.BIGFONTSIZE).fontColor('#FFF') + } + .width('100%') + .backgroundColor('#38260B') + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + top: 12, + bottom: 12, + left: 8, + right: 3 + }) + }.margin({ top: 35 }).padding({ left: 20, right: 20 }).alignItems(HorizontalAlign.Start) + } + } + .backgroundImage($rawfile('judge/score_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(514) + .height(618) + .padding({ + top: 18, + bottom: 15, + left: 13, + right: 14 + }) + + //科目二 + if (this.examSubject == "2") { + Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { + List({}) { + ForEach(chunkArr(this.projects, 2), (item: [ProjectInfo, ProjectInfo]) => { + ListItem() { + Row() { + Row() { + //#FF7566 #00FFD5 #E6DECF + // Text(this.projectsObj[item[0].projectCode]) + Text(item[0].abbreviation) + .fontSize(item[0].abbreviation.length > 5 ? 28 : 32) + .fontColor(this.getProjectColor(item[0])) + } + .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width('48.5%') + .height(115) + .margin({ bottom: 5 }) + .justifyContent(FlexAlign.Center) + + if (item[1]) { + Row() { + //#FF7566 #00FFD5 #E6DECF + Text(item[1].abbreviation) + .fontSize(item[1].abbreviation.length > 5 ? 28 : 32) + .fontColor(this.getProjectColor(item[1])) + } + .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width('48.5%') + .height(115) + .margin({ left: 5, bottom: 5 }) + .justifyContent(FlexAlign.Center) + } + } + } + }); + } + } + .backgroundImage($rawfile('judge/project_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width('57%') + .height('100%') + .padding(30) + .margin({ right: 10 }) + } + //科目三 + if (this.examSubject == '3') { + Column() { + Flex({ + wrap: FlexWrap.Wrap, + direction: FlexDirection.Row, + justifyContent: FlexAlign.SpaceBetween + }) { + List({}) { + ForEach(this.projects, (project: ProjectInfo) => { + ListItem() { + Text(project.name) { + } + .fontColor(this.getProjectColor(project)) + .margin({ bottom: 2 }) + .fontSize(24) + }.margin({ bottom: 2 }) + }) + }.lanes(2).margin({ left: 25 }) + } + .width('100%') + .height('57%') + .backgroundImage($rawfile('judge/project_km3_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .padding(30) + .margin({ right: 5 }) + + if (this.projects.length) { + Flex({ + wrap: FlexWrap.Wrap, + direction: FlexDirection.Row, + justifyContent: FlexAlign.SpaceAround + }) { + List() { + ForEach(this.artSubject3Projects, (item: string, index) => { + ListItem() { + } + .backgroundImage( + $rawfile( + `judge/km3/${this.getIsExitManualProject(index) ? (this.getIsEndManualProject(index)) : + (item + '_gray')}.png` + ), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(174) + .height(118 * 0.95) + .margin({ bottom: 8 }) + .onClick(() => { + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) + this.setManualProjectFn(index) + }) + }) + }.lanes(3).margin({ left: 5, top: 12 }) + } + } + + } + .backgroundImage($rawfile('judge/project_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .width(660) + .height(640) + .padding(44) + .margin({ right: 10 }) + } + }.margin({ top: 15 }).height('80%').justifyContent(FlexAlign.SpaceBetween) + }.width('100%').height('100%').alignItems(HorizontalAlign.Start).margin({ top: 10 }) + }.height('100%').alignItems(HorizontalAlign.Start) + }.width('75%').height('100%') + + Column() { + Column() { + Row() { + Text(this.totalScore <= 0 ? '0' : this.totalScore + '').fontColor('#FFEECC').fontSize(55) + Text('分').fontColor('#FFEECC').fontSize(30).padding({ top: 5 }) + } + .width(334) + .height(120) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .border({ width: 5, color: '#4D4136', radius: 30 }) + .onClick(() => { + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) + this.signDisplayComVisible = true + }) + + Row() { + Image(this.kszp).width('85%').height('85%') + } + .width(226) + .height(312) + .backgroundImage($rawfile('judge/photo_bg.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .margin({ top: 30, bottom: 15 }) + } + + Column() { + if (this.getIsManualKf()) { + Row() { + Row() { + } + .width(60) + .height(60) + .backgroundImage($rawfile('judge/manual_judge.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + + Text('人工评判').fontColor('#FFF').fontSize(32).padding({ right: 12 }) + } + .width(334) + .height(110) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .margin({ bottom: 10 }) + .onClick(() => { + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) + this.isDeductedPopShow = true + }) + } + + Row() { + Row() { + } + .width(60) + .height(60) + .backgroundImage($rawfile('judge/phone.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + + Text('呼叫请求').fontColor('#FFF').fontSize(32).padding({ right: 12 }) + } + .width(334) + .height(110) + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + .backgroundImage($rawfile('judge/button_nor.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .margin({ bottom: 10 }) + + Row() { + } + .width(334) + .height(100) + .backgroundImage($rawfile('judge/anniu_nor.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '100%', height: '100%' }) + .onClick(() => { + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) + if (Reflect.get(this.judgeConfigObj, '353') == '0') { + this.endPopupVisible = true + } else { + Prompt.showToast({ + message: '车上不允许手动结束考试!', + duration: 4000 + }); + } + }) + }.margin({ bottom: 30 }) + + } + .width('25%') + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .alignItems(HorizontalAlign.Center) + .margin({ bottom: 20 }) + } + .height('90%') + .justifyContent(FlexAlign.Start) + .padding({ + top: 37, + left: 60, + bottom: 35, + right: 60 + }) + + + //科目三人工扣分弹窗 + if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj, '342') == '0') { + DeductedPopup({ + defaultTabIndex: this.defaultTabIndex, + currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { + const project: ProjectInfo = Reflect.get(this.projectsObj, projectKey) + return project.type == '2' ? project.projectCode : undefined + }).filter(project => project !== undefined), + markRules: this.manualMarkRules, + closePopup: () => { + this.isDeductedPopShow = false; + this.defaultTabIndex = 0; + }, + confirmMark: async (itemno: string, serial: string) => { + clearTimeout(this.popTimer) + this.popTimer = null + this.popTimer = setTimeout(async () => { + const judge = this.judge + await judge.setJudgeMark(itemno, serial); + this.isDeductedPopShow = false + this.popTimer = null; + }, 500) + } + }) + } + + if (this.signDisplayComVisible) { + Column() { + SignDisplayCom({ + showBack: false, + scaleNum: 1.8, + msgStr: this.judge.plcStr || '', + showTrajectory: this.singlePlay ? true : (this.syssetParam623), + }).margin({ top: 100 }) + + Row() { + } + .width(240) + .height(240) + .position({ x: '81%', y: 80 }) + .backgroundImage($rawfile('judge/close.png'), ImageRepeat.NoRepeat) + .backgroundImageSize({ width: '33.33%', height: '33.33%' }) + .onClick(() => { + // this.vocObj.playAudio({ + // type: 1, + // name: 'button_media.wav' + // }) + this.signDisplayComVisible = false + }) + }.width('100%').height('100%').position({ y: 0 }).backgroundColor('rgba(0,0,0,0.6)') + } + + //科目三人工项目确认框 + if (this.isAmplifyPopShow && this.examSubject == '3') { + AmplifyPopup({ + amplifyImgIndex: this.amplifiedImgIndex, + confirmAmplify: async (amplify: AmplifyItem) => { + clearTimeout(this.popTimer) + this.popTimer = null + this.popTimer = setTimeout(async () => { + const judge = this.judge + await judge.setJudgeItem(amplify.projectCode, 1); + this.isAmplifyPopShow = false + this.popTimer = null; + }, 500) + }, + closeAmplifyPop: () => { + this.isAmplifyPopShow = false + } + }) + } + + //结束考试弹窗 + if (this.endPopupVisible) { + EndPoPup({ + title: '确定结束考试吗?', + cancelFn: () => { + this.endPopupVisible = false; + }, + confirmFn: async () => { + if (this.isErrorMsgEnd) { + this.judge.closeAllFiles() + router.back() + return + } + if (Reflect.get(this.judgeConfigObj, '344') == 1) { + Prompt.showToast({ + message: '考试未结束,不允许手动退出!', + duration: 4000 + }); + return + } + this.endPopupVisible = false; + this.loadingPopupVisible = true + clearInterval(this.timer); + clearInterval(AppStorage.get('judgeTimer')) + try { + this.judge.checkExamIsEnd(true); + } catch (e) { + this.judge.closeAllFiles() + router.back() + } + + } + }) + } + + //loading 弹窗 + if (this.loadingPopupVisible) { + LoadingPopup({ + title: '正在生成考试记录,请稍后...', + }) + } + + if (this.errorMsg) { + MsgPopup({ + title: this.errorMsg, + confirmFn: () => { + this.errorMsg = '' + this.isErrorMsgEnd = true; + if (this.disConnectErrorOpen) { + this.context.terminateSelf() + } else { + router.back() + } + }, + }) + } + + if (this.dwztErrorVisible) { + DwztErrorPopup({ + title: '当前差分状态异常,学员将无法正常进行考试评判,请将车辆行驶到开阔地,等待程序自检,差分正常后会自动关闭该对话框', + cancelFn: () => { + this.dwztErrorVisible = false; + }, + confirmFn: () => { + clearInterval(this.timer); + clearInterval(AppStorage.get('judgeTimer')) + this.judge.checkExamIsEnd(true); + }, + }) + } + + if (this.disConnectErrorOpen) { + + } + } + .height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) + } + + getProjectColor(project: ProjectInfo) { + const type = project.type; + switch (type) { + case '1': + return '#E6DECF'; + break; + case '2': + return '#FFAD33'; + break; + case '3': + return '#ff109d0a'; + break; + case '4': + return '#FF7566'; + break; + default: + return '#E6DECF'; + break; + } + } + + //人工项目操作 + async setManualProjectFn(index: number) { + + const judgeConfigObj = this.judgeConfigObj; + const isManualProjectIn = this.isManualProjectIn; + const getIsExitManualProject = this.getIsExitManualProject; + const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr; + const projectsObj = this.projectsObj; + + const projectCode = Reflect.get(artSubject3ProjectsCodesArr, index) + if (index === 5) { + console.info('surenjun 靠边停车状态=> ', getIsExitManualProject(index)) + } + const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode) + if (getIsExitManualProject(index)) { + // 正在进行的项目 取消项目 + if (isManualProjectIn && currentProject.type == '2') { + //判断人工是否能取消项目 && 当前项目有扣分的不能取消 + if (Reflect.get(this.judgeConfigObj, '340') == 1) { + await this.judge.setJudgeItem(projectCode, 2); + Prompt.showToast({ + message: '项目取消', + duration: 2000 + }) + return + } + } + + // 靠边停车时候可以触发 + if (Reflect.get(this.judgeConfigObj, '343') === '0') { + const xmmcStr = this.xmmcStr; + if (xmmcStr == '无' || xmmcStr == '') { + //512[6] 人工项目按钮放大确认 + const param512: string[] = (Reflect.get(this.judgeConfigObj, '512') || '').split(','); + console.info('surenjun', param512) + if (param512[6] !== '0') { + this.amplifiedImgIndex = index; + this.isAmplifyPopShow = true + } else { + const judge = this.judge + await judge.setJudgeItem(projectCode, 1); + } + } else { + if (index === 5) { + Prompt.showToast({ + message: `${xmmcStr}未结束,不允许靠边停车`, + duration: 8000 + }); + } + } + } else { + this.amplifiedImgIndex = index; + this.isAmplifyPopShow = true + } + } + } + + // 获取是否能人工进项目 + getIsExitManualProject = (index: number) => { + + const judgeConfigObj = this.judgeConfigObj; + const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr; + const projectsObj = this.projectsObj; + const carztStr = this.carztStr; + const isManualProjectIn = this.isManualProjectIn; + const isProjectIn = this.isProjectIn; + const getProjectIsInRoad = this.getProjectIsInRoad; + + const projectCode = artSubject3ProjectsCodesArr[index]; + const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode) + if (currentProject === undefined) { + return false + } + const projectType = currentProject.type; + + //不允许人工触发的项目列表,以","分隔 + const unExitManualProjects: string[] = Reflect.get(this.judgeConfigObj, '332').split(',') || []; + //直线行驶中不进其他考试项目(0-否 1-是) + const param348: string = Reflect.get(this.judgeConfigObj, '348') || '0', + //里程不够允许手工点靠边停车(0-否 1-是) + param387: string = Reflect.get(this.judgeConfigObj, '387') || '0', + //里程不够不报靠边停车(0-否+1-是+2-必考项目未完成且里程不够不报项目) + param319: string = Reflect.get(this.judgeConfigObj, '319') || '0', + //人工项目是否能取消 1:可取消; + param340: string = Reflect.get(this.judgeConfigObj, '340') || '0', + //307参数里设置的项目,项目已经做过,后续不能人工触发; + param307: string[] = (Reflect.get(this.judgeConfigObj, '307') || '').split(','); + + //非行驶状态(没有速度),人工项目不能触发(按钮灰色) + if (carztStr === '停车') { + return false + } + + //车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能) + if (Reflect.get(this.judgeConfigObj, '342') === '3' || Reflect.get(this.judgeConfigObj, '342') === '2') { + return false + } + + //不允许人工触发的项目列表 + if (unExitManualProjects.includes(artSubject3ProjectsCodesArr[index])) { + return false + } + + //项目进行中不能人工触发 + if (isProjectIn) { + if (param340 == '1') { + if (isManualProjectIn && (currentProject.type == '2')) { + return true + } else { + return false + } + } + return false + } + + //项目路段信息判断 + if (!getProjectIsInRoad(projectCode + '')) { + return false + } + + const project_9: ProjectInfo = Reflect.get(projectsObj, '9') + // 直线行驶中不进其他考试项目(0-否 1-是) + if (param348 == '0' && project_9.type == '2') { + return index === 0 ? true : false + } + + //项目已经做过,后续不能人工触发 + if (param307.includes(projectCode) && (projectType == '3' || projectType == '4')) { + return false + } + + //319不为0,或者387不为1,里程不够时,靠边停车项目不能触发 + if ((param387 != '1' || param319 != '0') && index === 5) { + const examMileage = this.examMileage + const isRequiredProjectsEnd = this.isRequiredProjectsEnd + const jl = this.jl + //里程是否达标 && 必考项目是否全完成 + return jl >= Number(examMileage) && isRequiredProjectsEnd + } + return true + } + // 判断项目是否在当前路段号 + getProjectIsInRoad = (projectCode: string,) => { + const judgeConfigObj = this.judgeConfigObj; + const lane = this.lane; + const road = lane.road; + const num = lane.num; + const count = lane.count; + + 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 = { + //直线行驶 + param_3, + //变更车道 + param_4, + //超车 + param_10, + //靠边停车 + param_11, + //会车 + param_9, + //掉头 + param_12, + }; + + + //未测绘得道路上或者不在差分状态 + if (road === '') { + return false + } + const currentProjectRoad: string[] = Reflect.get(projectRoads, `param_${projectCode}`) + if (currentProjectRoad.length == 0) { + return true + } + + //设置了514-519参数,只能在设置的路段触发对应项目 + if (currentProjectRoad.includes(road)) { + //如果525为1,则514-519设置的路段不能触发对应项目 + if (Reflect.get(this.judgeConfigObj, '525') == '1') { + return false + } + } else { + return false + } + + //405参数为2是,如果在最左侧车道,超车项目不能触发; + if (projectCode == '10' && + Reflect.get(this.judgeConfigObj, '405') == '2' && + (num === count) && + num > 0 + ) { + return false + } + + // 车道总数少于2条,超车和变道不能触发 + if (projectCode == '10' || projectCode == '4') { + if (count < 2) { + return false + } + } + return true + + } + // 获取人工项目是否已做 + getIsEndManualProject = (index: number) => { + const projectName = this.artSubject3Projects[index]; + const projectCode = this.artSubject3ProjectsCodesArr[index]; + const currentProject: ProjectInfo = Reflect.get(this.projectsObj, projectCode) + const type = currentProject.type + if (type == '2') { + return projectName + } + return (type == '3' || type == '4') ? `${projectName}_red` : `${projectName}_green`; + } + // 获取是否能进行人工评判 + getIsManualKf = () => { + if (this.examSubject == '3') { + //杭州训练模式不允许人工评判 + if (this.singlePlay && Reflect.get(this.judgeConfigObj, '211') == 'zjhz') { + return false + } + if (Reflect.get(this.judgeConfigObj, '342') == '0') { + return true + } + } else { + return false + } + } +} + +export const JudgePage = Index diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 3268a0e8..75320021 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -13,7 +13,7 @@ import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData'; import BoardPrePareSetPopup from './compontents/judge/BoardPrePareSetPopup'; import LoadingPopup from './compontents/judge/LoadingPopup'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; -import { judgeConfig } from './judgeSDK/utils/judgeConfig'; +import { JudgeConfig } from './judgeSDK/utils/judgeConfig'; // import { initJudgeUdp } from '../common/utils/UdpJudge'; import errorMsgDialog from './compontents/errorMsgDialog'; import imageBtn from './compontents/imageBtn'; @@ -44,6 +44,7 @@ import dayTs from '../utils/Date'; import { GetCurrentTime, NumberToByteArray } from '../utils/Common'; import DB from '../utils/DbSql'; import { CenterUDPClientInstance } from '../utils/business/CenterUdpBusiness'; +import { JudgeEmitterInstance } from '../utils/business/UdpEvent'; @Entry @Component @@ -295,14 +296,14 @@ struct UserInfo { // initJudgeUdp() // TODO UDP更改 //监听远程开始考试 - // globalThis.udpEvent.onBeginExam(async () => { - // console.info('surenjun', 'userInfo收到UdpEvent事件') - // if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { - // await this.prePareSCZB() - // } else { - // await this.prePareExam() - // } - // }) + JudgeEmitterInstance.onBeginExam(async () => { + console.info('surenjun', 'userInfo收到UdpEvent事件') + if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { + await this.prePareSCZB() + } else { + await this.prePareExam() + } + }) } @@ -911,7 +912,7 @@ struct UserInfo { return true } return new Promise((resolve, reject) => { - if (judgeConfig.isCheckFireOpen) { + if (JudgeConfig.isCheckFireOpen) { resolve(true) return } diff --git a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets index b25bf56f..479054f7 100644 --- a/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets +++ b/entry/src/main/ets/pages/compontents/judge/BoardPrePareSetPopup.ets @@ -1,4 +1,4 @@ -import { judgeConfig } from '../../judgeSDK/utils/judgeConfig'; +import { JudgeConfig } from '../../judgeSDK/utils/judgeConfig'; import common from '@ohos.app.ability.common'; import VoiceAnnounce from '../../judgeSDK/utils/voiceAnnouncements'; @@ -90,7 +90,7 @@ export default struct DeductedPopup { //上车准备 // this.universalMarkRules = this.markRules.filter(item => this.currentItems.includes(item.itemno+'')) // const { isTrajectoryOpen } = judgeConfig; - if (judgeConfig.isTrajectoryOpen) { + if (JudgeConfig.isTrajectoryOpen) { await this.initDb() } else { await this.initSysset() @@ -113,7 +113,7 @@ export default struct DeductedPopup { const examSubject = this.carInfo.examSubject; //轨迹回放读取 systemparam表、markrule表 const fileUtil = new FileUtils(this.context); - const folderPath = await fileUtil.initFolder(judgeConfig.trajectoryPath); + const folderPath = await fileUtil.initFolder(JudgeConfig.trajectoryPath); const str = await fileUtil.readFile(folderPath); const strArr = str.split('\n'); // const [initData, beginData] = [strArr[0], strArr[1]]; @@ -121,7 +121,7 @@ export default struct DeductedPopup { const beginData = strArr[1]; // TODO 补全类型 const initDataObj: ESObject = JSON.parse(initData); - this.examSubject = Number(judgeConfig.isTrajectoryOpen ? (initDataObj.kskm * 1) : examSubject); + this.examSubject = Number(JudgeConfig.isTrajectoryOpen ? (initDataObj.kskm * 1) : examSubject); await this.initMarkRules(initDataObj.mark); await this.initSysset(initDataObj.sysset); await this.initStudent() @@ -153,7 +153,7 @@ export default struct DeductedPopup { kfdm: kf.kfdm, }))) - if (judgeConfigObj['418'] == '1' || judgeConfig.kfVoiceOpen) { + if (judgeConfigObj['418'] == '1' || JudgeConfig.kfVoiceOpen) { avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`, `voice/mark_${Math.abs(mark.score)}.mp3`], false, () => { this.closePopup(true) }); diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 5ededb25..dc75b64f 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -9,7 +9,7 @@ import FileModel from './utils/fileModel'; import FilePhoto from './utils/filePhoto'; import FileLog from './utils/fileLog'; import JudgeTask from './utils/judgeTask'; -import { judgeConfig } from './utils/judgeConfig'; +import { JudgeConfig } from './utils/judgeConfig'; import { LANE } from '../judgeSDK/api/judgeSDK.d'; import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; @@ -55,16 +55,16 @@ import { JudgeConfigObj, JudgeEventKf, JudgeInitObj, - JudgeKfxm, - JudgeKsjs, - JudgeKsxm, + JudgeKFXM, + JudgeKSJS, + JudgeKSXM, JudgePerformInfo, JudgeSound, JudgeUI, - JudgeXmjs, + JudgeXMJS, Km3JudgeInitConfig, KmItem, - KmItems, + JudgeConfigObjKmItems, MarkRule, Plc, ProjectInfo, @@ -402,10 +402,10 @@ export default class Judge { } } } - private ksjs: JudgeKsjs + private ksjs: JudgeKSJS private kfArr: JudgeEventKf[] //所有的科目考试项目(大车&小车) - private kmItems: KmItems + private kmItems: JudgeConfigObjKmItems private plcData: Plc // 获取plc数据 getPlcData = async (plc: string) => { @@ -686,9 +686,9 @@ export default class Judge { this.carztStr = ''; this.kmItems = {}; // 考试回放配置 - this.isTrajectoryOpen = judgeConfig.isTrajectoryOpen; - this.modelPath = judgeConfig.modelPath; - this.trajectoryPath = judgeConfig.trajectoryPath; + this.isTrajectoryOpen = JudgeConfig.isTrajectoryOpen; + this.modelPath = JudgeConfig.modelPath; + this.trajectoryPath = JudgeConfig.trajectoryPath; this.isExam = !this.judgeUI.singlePlay; (judgeUI.examSubject == '2' ? testKm2Items : testKm3Items).forEach(item => { @@ -794,8 +794,8 @@ export default class Judge { const ddxkKfArr = judgeUI.ddxkKfArr const passingScore = judgeUI.passingScore - const ksxm: JudgeKsxm[] = projects.map(project => { - const temp: JudgeKsxm = { + const ksxm: JudgeKSXM[] = projects.map(project => { + const temp: JudgeKSXM = { xmdm: Number(project.projectCode), xmxh: '' } return temp @@ -806,10 +806,10 @@ export default class Judge { return Number(currentProject.projectCode) })) || []; - const kfxm: JudgeKfxm[] = isDdxk ? (ddxkKfArr?.map(kf => { + const kfxm: JudgeKFXM[] = isDdxk ? (ddxkKfArr?.map(kf => { return { xmdm: Number(kf.split(',')[0]), kfdm: kf.split(',')[1] - } as JudgeKfxm + } as JudgeKFXM })) : [] const beginInfo: JudgeBeginObj = { @@ -1059,7 +1059,7 @@ export default class Judge { } // 更改考试状态 goVoiceAnnounce = - async (event: number, xmdm: number, kf: JudgeEventKf[], xmjs: JudgeXmjs, ksjs: JudgeKsjs, xmxh: string) => { + async (event: number, xmdm: number, kf: JudgeEventKf[], xmjs: JudgeXMJS, ksjs: JudgeKSJS, xmxh: string) => { const beginProject = this.beginProject const pointsDedute = this.pointsDedute @@ -1164,7 +1164,7 @@ export default class Judge { console.info('surenjun', '扣分开始') //扣分时实时播报语音(0-否+1-是) const currentKf = kf[kfLen -1]; - if (judgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '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`]) } diff --git a/entry/src/main/ets/pages/judgeSDK/utils/fileModel.ets b/entry/src/main/ets/pages/judgeSDK/utils/fileModel.ets index 14965b0c..de1311d7 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/fileModel.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/fileModel.ets @@ -53,8 +53,7 @@ export default class FileModel { //获取文件内容 public getModelContent = (folderPath:string, fileName:string) => { try { - const content = this.fileUtil.getFileContent(`${folderPath}/${fileName}`) - return content; + return this.fileUtil.getFileContent(`${folderPath}/${fileName}`); } catch (e) { console.info('surenjun', JSON.stringify(e)) promptAction.showToast({ diff --git a/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ets b/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ets index 9818384d..7a3f8463 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ets @@ -1,6 +1,6 @@ import { takePhoto } from '../../../utils/Video'; import promptAction from '@ohos.promptAction'; -import { judgeConfig } from './judgeConfig'; +import { JudgeConfig } from './judgeConfig'; import FileUtils from '../../../utils/FileUtils'; import {VideoConfig} from '../../../model/Common' import common from '@ohos.app.ability.common'; @@ -9,7 +9,7 @@ export default class FilePhoto { private params: VideoConfig private context:common.UIAbilityContext public getPhoto = async () => { - if (!judgeConfig.isPhotoOpen) { + if (!JudgeConfig.isPhotoOpen) { return '' } else { try { diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts index a8e1b4f1..4b673a1f 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts @@ -1,5 +1,5 @@ //考试回放开关 -export const judgeConfig = { +export const JudgeConfig = { //本地目录开关 isTrajectoryOpen: false, //是否开启拍照 diff --git a/entry/src/main/ets/utils/UdpUtils.ets b/entry/src/main/ets/utils/UdpUtils.ets index 9418d22c..6f5fcfa3 100644 --- a/entry/src/main/ets/utils/UdpUtils.ets +++ b/entry/src/main/ets/utils/UdpUtils.ets @@ -41,6 +41,22 @@ export default class UdpClient { private errorEvents: Array = [] private dealMethod: DealMethod + private bindEvent() { + this.udp?.on("message", value => { + let result = this.dealMethod(value.message) + this.messageEvents.forEach(cb => { + cb(result) + }) + }) + this.udp.on("error", (err) => { + console.log(UDPTag, 'udp error', JSON.stringify(err)) + this.errorEvents.forEach(cb => { + cb(err) + }) + }) + } + + bindUdp(): Promise { return this.udp.bind({ address: this.localIp, port: parseInt(this.localIpPort), family: 1 @@ -55,8 +71,11 @@ export default class UdpClient { } close(): Promise { - this.udp.off("message") - this.udp.off("error") + this.messageEvents = [] + this.errorEvents = [] + this.dealMethod = null + this.udp?.off("message") + this.udp?.off("error") return this.udp?.close() } @@ -88,7 +107,8 @@ export default class UdpClient { this.sendMsg(msgData) } - create(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { + async create(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { + await this.close() this.localIp = udpLocalIp this.oppositeIp = udpOppositeIp this.localIpPort = udpLocalIpPort @@ -112,21 +132,6 @@ export default class UdpClient { offMsg(callback: Function) { this.messageEvents = this.messageEvents.filter(cb => cb !== callback) } - - private bindEvent() { - this.udp?.on("message", value => { - let result = this.dealMethod(value.message) - this.messageEvents.forEach(cb => { - cb(result) - }) - }) - this.udp.on("error", (err) => { - console.log(UDPTag, 'udp error', JSON.stringify(err)) - this.errorEvents.forEach(cb => { - cb(err) - }) - }) - } } // 获取后置机信号 diff --git a/entry/src/main/ets/utils/business/JudgeUdpBusiness.ets b/entry/src/main/ets/utils/business/JudgeUdpBusiness.ets index 4a6b1e72..fa0f2856 100644 --- a/entry/src/main/ets/utils/business/JudgeUdpBusiness.ets +++ b/entry/src/main/ets/utils/business/JudgeUdpBusiness.ets @@ -1,7 +1,7 @@ import { CarInfoType, EnvironmentConfigurationType, Gps, Sensor, UDPParamType } from '../../model' import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest'; import { fillZero, } from '../../pages/judgeSDK/utils/Common'; -import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; +import { JudgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; import { FillZero, StringToASCII } from '../Common'; import UdpClient from '../UdpUtils' import { CenterUDPClientInstance } from './CenterUdpBusiness'; @@ -49,8 +49,8 @@ function string2Bytes(num: number | string, len: number) { class JudgeUdpBusiness { private static instance: JudgeUdpBusiness private udp: UdpClient - private udpIndex = 0; private currentUdpIndex = 0; + public udpIndex = 0; constructor() { if (!JudgeUdpBusiness.instance) { @@ -203,7 +203,6 @@ class JudgeUdpBusiness { dwsxs: p[84], jdsxs: Number(origin[92].split('-')[1]) } - return { sensor, gps, @@ -231,9 +230,9 @@ class JudgeUdpBusiness { } } - private async getMessageHeartbeat(msg: string): Promise { + async getMessageHeartbeat(msg: string): Promise { const carInfo: CarInfoType = AppStorage.get('carInfo') - let gpsDigit = judgeConfig.fourInOneScreen.gpsDigit + let gpsDigit = JudgeConfig.fourInOneScreen.gpsDigit const asclshArr = StringToASCII(FillZero( AppStorage.get("singlePlay") ? '1111111111111' diff --git a/entry/src/main/ets/utils/business/UdpEvent.ets b/entry/src/main/ets/utils/business/UdpEvent.ets index 86c0c482..7e6949fc 100644 --- a/entry/src/main/ets/utils/business/UdpEvent.ets +++ b/entry/src/main/ets/utils/business/UdpEvent.ets @@ -14,7 +14,7 @@ enum EventId { endExamEventId = 12 } -export default class JudgeEmitter { +class JudgeEmitter { private beginExamCallBack: Function = () => { } private endExamCallBack: Function = () => { @@ -23,10 +23,6 @@ export default class JudgeEmitter { } private directives: string - constructor() { - this.init() - } - //监听开始考试 public onBeginExam(callBack?: Function) { console.info('surenjun', '注册远程开始考试事件') @@ -124,3 +120,5 @@ export default class JudgeEmitter { } } +export const JudgeEmitterInstance = new JudgeEmitter() + diff --git a/entry/src/main/ets/utils/business/UdpJudge.ets b/entry/src/main/ets/utils/business/UdpJudge.ets deleted file mode 100644 index 0aa0a3fb..00000000 --- a/entry/src/main/ets/utils/business/UdpJudge.ets +++ /dev/null @@ -1,314 +0,0 @@ -import systemTime from '@ohos.systemDateTime'; - -import { testKm2Items, testKm3Items } from '../../pages/judgeSDK/dataTest/index'; -import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; -import { examCalcGpsDistance } from '../../pages/judgeSDK/api'; -import { judgeUDPClient, lightUDPClient, objUDPClient } from '../UdpUtils'; -import { CarInfoType, Gps, Sensor } from '../../model'; -import { FillZero, StringToASCII } from '../Common'; - -interface PLCDataType { - sensor: Sensor, - gps: Gps, -} - -interface ProjectDataType { - code: string - status: number -} - -interface ProjectItemType { - code: ProjectDataType - status: string -} - -function convertGpsCoord2(num: number) { - const tempNum = Math.floor(num); - const du = Math.floor(tempNum / 100); - const fen = tempNum % 100 + num - tempNum; - return du + fen / 60 -} - -function string2Bytes(num: number | string, len: number) { - let str = (Math.floor(Number(num))).toString(2); - if (str.length > len) { - console.log('数据长度不对~~'); - return - } - let byteString = FillZero(str, len); - - let arrBytes: number[] = []; - for (let i = byteString.length; i > 0; ) { - let j = i - 8; - if (j < 0) { - j = 0 - } - let s = byteString.slice(j, i); - let v = parseInt(s, 2); - arrBytes.push(v); - i = i - 8 - } - return arrBytes; -} - -// 中心plc实时信号转换成字节 -function getTranslateSignals(tempItems: number[]) { - const len = Math.floor(tempItems.length / 8); - const arr: string[] = []; - for (let i = 0; i < len; i++) { - arr.push(tempItems.slice(i * 8, (i + 1) * 8).join('')); - } - return arr.map(numStr => parseInt(numStr, 2)).map(item => string2Bytes(item, 8)[0]) -} - -// 中心所有项目转换 -function getTranslateProject(): string[] { - const examSubject = AppStorage.get("examSubject"); - const tempItems: ProjectItemType[] = - (examSubject === '2' ? testKm2Items : testKm3Items).map((code: ProjectDataType) => { - let data: ProjectItemType = { - code, - status: '0' - } - return data - }) - 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' - //bit36-bit39保留 - ? tempArr.concat(['00', '00']) - //bit30-bit39保留 - : tempArr.concat(['00', '00', '00']) - } - - arr.push(tempArr.join('')); - } - return arr -} - -// plc数据转换成对象 -async function getPlcData(plc: string): Promise { - const time = await systemTime.getCurrentTime() - let origin = plc.split(",") - let p = origin.map(item => Number(item)) - let sensor: Sensor = { - aqd: p[19], - mkg: p[14], - ssc: p[13], - jsc: p[12], - fsc: p[18], - lhq: p[17], - lb: p[4], - skd: p[9], - jgd: p[7], - ygd: p[8], - //左方向灯 右方向灯 双跳灯 雾灯 雨刮器 点火1 点火2 发动机转速 档位 车速 - zfxd: p[2], - yfxd: p[3], - shtd: p[20], - wd: p[10], - ygq: p[11], - dh1: p[5], - dh2: p[6], - fdjzs: p[25], - dw: p[28], - cs: p[23], - fxp: Number(origin[27].split('_')[0]), - //累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量 - ljmc: p[24], - lcmc: 0, - csbzh: p[32], - csbyh: p[30], - csbyq: p[31], - csbzq: p[29], - zy: 0, - tbp: 0, - hsj: 0, - dcj: 0, - gx: 0, - yl: 0, - yy: 0, - sde: 0, - xhd: '', - rmndg: 0, - wav: 0, - mndg: '' - } - let gps: Gps = { - bklx: p[56], - dwzt: p[83], - jdzt: Number(origin[92].split('-')[0]), - sj: time, - jd: p[96], - wd: p[95], - hxj: p[90], - fyj: p[91], - hbg: p[85], - gdc: p[86], - sd: p[97], - age: p[87], - jdyz: p[89], - wdyz: p[88], - dwsxs: p[84], - jdsxs: Number(origin[92].split('-')[1]) - } - - return { - sensor, - gps, - } -} - -function getDwStatusType(dw: number) { - switch (dw) { - case 0: - return [0, 0, 0, 0] - case 1: - return [0, 0, 0, 1] - case 2: - return [0, 0, 1, 0] - case 3: - return [0, 0, 1, 1] - case 4: - return [0, 1, 0, 0] - case 5: - return [0, 1, 0, 1] - case 9: - return [1, 0, 0, 1] - default: - return [0, 0, 0, 0] - } -} - -export async function initJudgeUdp() { - AppStorage.setOrCreate("serialIndex", 0) - AppStorage.setOrCreate("udpIndex", 0) - const arrBlue = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]; - const arrBlueBuffer = new Uint8Array(arrBlue).buffer - lightUDPClient.sendMsg(arrBlueBuffer); - let prevJd = 0, preWd = 0 - objUDPClient.onMsg(async (msg: string) => { - const stashArr = msg.split(',') - if (stashArr[0] != '#DN_GD') { - return - } - const udpIndex = AppStorage.get("udpIndex"); - const isJudge = AppStorage.get("isJudge"); - if (udpIndex % 5 === 0 && !isJudge) { - const bytes = await getMessageHeartbeat(msg); - const msgArr: string[] = msg.split(','); - const jd = convertGpsCoord2(Number(msgArr[96])); - const wd = convertGpsCoord2(Number(msgArr[95]) || 0); - judgeUDPClient.send(bytes) - if (prevJd && Number(msgArr[83]) === 4) { - const distance = await examCalcGpsDistance({ - jd1: prevJd, - wd1: preWd, - jd2: jd, - wd2: wd, - h: Number(msgArr[90]) || 1, - }) - //@ts-ignore - // globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) - } - prevJd = jd; - preWd = wd; - } - AppStorage.set("udpIndex", udpIndex + 1) - }) -} - -export async function getMessageHeartbeat(msg: string): Promise { - const carInfo: CarInfoType = AppStorage.get('carInfo') - let gpsDigit = judgeConfig.fourInOneScreen.gpsDigit - const asclshArr = StringToASCII(FillZero( - AppStorage.get("singlePlay") - ? '1111111111111' - : AppStorage.get("lsh"), - 13)); - const ascksyhArr = StringToASCII(carInfo.examSubject === '2' ? '0000000000000' : '1111111111111') - const ascsbxhArr = StringToASCII('00000000') - const serialIndex = AppStorage.get("serialIndex") - const plcData = await getPlcData(msg); - let param: number[] = Object.entries(plcData.sensor) - .filter((item: [string, number]) => { - let keys = - ["zfxd", "yfxd", "shtd", "ygd", "jgd", "skd", "dh1", "dh2", "lhq", "jsc", "ssc", "fsc", "lb", "mkg", "aqd"] - return keys.indexOf(item[0]) - }) - .map((item: [string, number]) => item[1]) - .concat(getDwStatusType(plcData.sensor.dw)) - .concat([0, 0, plcData.sensor.ygq, plcData.sensor.wd, 0]) - const translateSignals = getTranslateSignals(param) - const translateProject = getTranslateProject(); - const translateJd = Number(convertGpsCoord2(plcData.gps.wd).toFixed(gpsDigit)) * Math.pow(10, gpsDigit); - const translateWd = Number(convertGpsCoord2(plcData.gps.jd).toFixed(gpsDigit)) * Math.pow(10, gpsDigit) - const translateProjects = translateProject.map(numStr => string2Bytes(parseInt(numStr, 2), 8)[0]) - let tempSd = Number((plcData.gps.sd * 1.852).toFixed(0)) - if (tempSd < 1) { - tempSd = 0 - } - const arr: number[][] = [ - //考生号 - asclshArr.map(lsh => string2Bytes(lsh, 8)[0]), - //考试员号 - ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]), - //科目类型(0:未考试 1:科目二 2:科目三) + 考试开始时间 - string2Bytes(`${0}${'00:00:000'}`, 4 * 8), - // 消息序号 - string2Bytes(serialIndex, 2 * 8), - translateSignals, - string2Bytes(tempSd * 100, 2 * 8), - string2Bytes(plcData.sensor.fdjzs / 100, 8), - string2Bytes(translateJd, 4 * 8), - string2Bytes(translateWd, 4 * 8), string2Bytes(1, 8), - //GPS东向距离 - string2Bytes(0, 4 * 8), - //GPS北向距离 - string2Bytes(0, 4 * 8), - //航向角 - string2Bytes(plcData.gps.hxj * 100, 2 * 8), - //俯仰角 - string2Bytes(plcData.gps.fyj * 100, 2 * 8), - // 高程(海拔) - string2Bytes(plcData.gps.hbg * 100, 4 * 8), - //dddd - translateProjects, - //当前项目编号 - string2Bytes(0, 8), - //场地设备编号 - ascsbxhArr.map(sbxh => string2Bytes(sbxh, 8)[0]), - //本次考试行驶距离 - string2Bytes(0, 2 * 8), - //扣分值 - string2Bytes(0, 2 * 8), - //扣分数 - string2Bytes(0, 2 * 8), - //扣分项数量 - string2Bytes(0, 8), - //n个扣分序号 - // [].map(kf => string2Bytes(kf.markcatalog, 8)), - [], - //牵引车第二gps精度、纬度 - string2Bytes(0, 4 * 8), string2Bytes(0, 4 * 8), - //牵引车第二航向角 - string2Bytes(0, 2 * 8), - //摩托压线 Byte[20], - string2Bytes(0, 20 * 8), - //考试用时 - string2Bytes(FillZero(0, 4), 4 * 8), - //项目用时 - string2Bytes(FillZero(0, 2), 2 * 8), - //设备信号状态 - string2Bytes(0, 4 * 8), - ] - let result: number[] = []; - arr.forEach(itemArr => { - result = result.concat(itemArr) - }) - AppStorage.setOrCreate("serialIndex", 0) - return [...new Uint8Array(result)] -}