From d697c69ceed7d6b21f1b90fe6b394616a6f3cfaf Mon Sep 17 00:00:00 2001 From: Surenjun Date: Thu, 27 Mar 2025 15:52:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20pages/Judge.ets=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/api/judge.ets | 5 +- entry/src/main/ets/model/Common.ets | 6 +- entry/src/main/ets/model/Judge.ets | 206 ++++++++++-- entry/src/main/ets/model/Table.ets | 3 + entry/src/main/ets/pages/Judge.ets | 312 ++++++++++-------- .../main/ets/pages/judgeSDK/api/judgeSDK.d.ts | 6 + .../main/ets/pages/judgeSDK/dataTest/index.ts | 2 +- entry/src/main/ets/pages/judgeSDK/judge.ets | 6 +- 8 files changed, 379 insertions(+), 167 deletions(-) diff --git a/entry/src/main/ets/api/judge.ets b/entry/src/main/ets/api/judge.ets index 88f90ff8..320812dc 100644 --- a/entry/src/main/ets/api/judge.ets +++ b/entry/src/main/ets/api/judge.ets @@ -197,7 +197,8 @@ interface UploadExamMileage { carId: string examinationRoomId: string lsh: string - kslc: string + kslc: number + kskssj:string } // 上传考试里程 @@ -208,7 +209,7 @@ export async function uploadExamMileage(params: UploadExamMileage) { if (singlePlay) { return } - const time = await GetCurrentTime() + const time = GetCurrentTime() return request({ url: '/der2/services/exam/uploadExamMileage.ws', data: ` diff --git a/entry/src/main/ets/model/Common.ets b/entry/src/main/ets/model/Common.ets index 2fb3d805..e7670b44 100644 --- a/entry/src/main/ets/model/Common.ets +++ b/entry/src/main/ets/model/Common.ets @@ -90,10 +90,14 @@ export interface BaseInfoType { deviceNo?: string } +interface kfdmObj{ + xmdm:string + kfdm:string +} // 路由参数 export interface RouteParamsType { sczb?: string; - kfdm?: string; + kfdm?: kfdmObj[]; type?: string; wayno?: string; kString?: string; diff --git a/entry/src/main/ets/model/Judge.ets b/entry/src/main/ets/model/Judge.ets index be5ef8ba..9267b5bc 100644 --- a/entry/src/main/ets/model/Judge.ets +++ b/entry/src/main/ets/model/Judge.ets @@ -1,7 +1,7 @@ // ------------------------------ // 基础共用类型 // ------------------------------ - +import {MA_SYSTEMPARMType} from './Table' /** 基础考试字段 */ interface BaseExamFields { kchp?: string; @@ -41,11 +41,16 @@ export interface UDPParamType { /** 扣分代码项 */ export interface KfdmType { - xmdm: number; - kfdm: string; - markreal: number; + + xmmcStr: string + xmdm: number + desc: string + score: number markcatalog: string; - score: number; + markserial: string + kfdm: string; + markreal?: number; + kfxh?: string } // ------------------------------ @@ -213,13 +218,15 @@ interface Qfsj { jl: number sd: number } -interface Show{ + +interface Show { bh: number - zb:Zb[] + zb: Zb[] } -interface Zb{ - x:number, - y:number + +interface Zb { + x: number, + y: number } /** 考试过程数据 */ @@ -238,19 +245,174 @@ export interface DrvexamType extends BaseExamFields { } -export interface DefaultJudgeConfigObj{ - param_302:string - param_332:string - param_342:string - param_343:string - param_344:string - param_348:string - param_353:string - param_369:string - param_375:string - param_387:string - param_432:string +export interface DefaultJudgeConfigObj { + param_302: string + param_332: string + param_342: string + param_343: string + param_344: string + param_348: string + param_353: string + param_369: string + param_375: string + param_387: string + param_432: string +} +export interface SyssetConfig { + key?: number + value?: string + name?: string +} + +export interface JudgeCallBacData { + xmmcStr?: string + carztStr?: string + kfArr?: MarkRule[] } +/** 考试过程中项目信息**/ +export interface ProjectInfo { + //项目名称 + name?: string + //项目代码 + projectCode?: string + //无锡所项目代码 + projectCodeCenter?: string + //项目简写 + abbreviation?: string + ///项目是否考过了 + isEnd?: boolean, + + //项目开始数据是否上传过 + isUpload?: boolean + //是否是必考 + isRequired?: boolean + //项目状态:未做 正在做 及格 不及格 有扣分 + type?: '1' | '2' | '3' | '4' | '5' +} + +/** 科目二项目代码 **/ +export type Km2XmdmEnum = 0 | 2 | 3 | 5 | 6 + +/** 科目三项目代码 **/ +export type Km3XmdmEnum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 41 + +/** 科目二无锡所项目代码 **/ +export type Km2WxXmdmEnum = 20100 | 20300 | 20400 | 20600 | 20700 + +/** 科目三无锡所项目代码 **/ +export type Km3WxXmdmEnum = 40100 | 40200 | 40300 | 40500 | 40700 | 41000 + | 41100 | 41200 | 41300 | 41400 | 40600 | 41500 | 41700 | 40400 | 40800 | 40900 + + +/** 考试过程中所有项目信息**/ +export interface ProjectInfos { + 0?: ProjectInfo + 2?: ProjectInfo + 3?: ProjectInfo + 5?: ProjectInfo + 6?: ProjectInfo + 1?: ProjectInfo + 4?: ProjectInfo + 7?: ProjectInfo + 8?: ProjectInfo + 9?: ProjectInfo + 10?: ProjectInfo + 11?: ProjectInfo + 12?: ProjectInfo + 14?: ProjectInfo + 15?: ProjectInfo + 16?: ProjectInfo + 41?: ProjectInfo +} + +export interface ProjectCenterInfos { + 20100?: ProjectInfo + 20300?: ProjectInfo + 20400?: ProjectInfo + 20600?: ProjectInfo + 20700?: ProjectInfo + + 40100?: ProjectInfo + 40200?: ProjectInfo + 40300?: ProjectInfo + 40500?: ProjectInfo + 40700?: ProjectInfo + 41000?: ProjectInfo + 41100?: ProjectInfo + 41200?: ProjectInfo + 41300?: ProjectInfo + 41400?: ProjectInfo + 40600?: ProjectInfo + 41500?: ProjectInfo + 41700?: ProjectInfo + 40400?: ProjectInfo + 40800?: ProjectInfo + 40900?: ProjectInfo +} + +export interface MarkRule { + itemno?: number + markcatalog?: string + markshow?: string + markserial?: string + markstandard?: number, + markreal?: number + kfxh?: string + onlyoneid?: number + OnlyOneKind?: number + nocancelid?: number + NoCancelId?: number + gps_sid?: number, + GPS_SID?:boolean + score?:number + xmmcStr?: string + desc?: string +} + +export interface UploadExamMileage { + carId: string + examinationRoomId: string + lsh: string + kslc: number + kskssj:string +} + +export interface SYSSET { + v_no: string, + v_name: string, + v_value: string + + /** 轨迹文件 **/ + key?:string; + name?:string; + value?:string; + +} + +/****** 评判初始化数据*****/ +export interface JudgeInitObj{ + name:string + kskm:string + systemparm:MA_SYSTEMPARMType[] + mark:MarkRule[] + sysset:SYSSET[] +} + +export interface ProjectRoads{ + param_3?:string[] + param_4?:string[] + param_10?:string[] + param_11?:string[] + param_9?:string[] + param_12?:string[] +} + + +/****** 评判开始考试数据*****/ +export interface JudgeBeginObj{ + exam:0|1 +} + diff --git a/entry/src/main/ets/model/Table.ets b/entry/src/main/ets/model/Table.ets index 822e92de..41eeb627 100644 --- a/entry/src/main/ets/model/Table.ets +++ b/entry/src/main/ets/model/Table.ets @@ -212,4 +212,7 @@ export interface MA_MARKRULEType { markshow?: string txt1?: string kfxh?: string + + + } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 8193d0d4..aec26c71 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -20,7 +20,6 @@ import { MarkRule, Project, ProjectObj, - SYSSET, SYSTEMPARMARR } from './judgeSDK/api/judgeSDK.d'; @@ -40,7 +39,18 @@ import { MA_SYSTEMPARMType, MASYSSETTableType, RouteParamsType, - User + User, + SYSSET, + SyssetConfig, + ProjectInfo, + ProjectInfos, + ProjectCenterInfos, + JudgeInitObj, + JudgeBeginObj, + UploadExamMileage, + AmplifyItem, + ProjectRoads, + JudgeCallBacData } from '../model'; import { GetSyncData } from '../utils/table/Operation'; import dayTs from '../utils/Date'; @@ -48,6 +58,7 @@ import { GetCurrentTime } from '../utils/Common'; import { chunkArr } from './judgeSDK/utils/Common'; import FileUtils from '../utils/FileUtils'; + @Entry @Component struct Index { @@ -78,20 +89,20 @@ struct Index { @State ddxkKfArr: string[] = [] @State xmmcStr: string = '' @State carztStr: string = '' - @State kfArr: KfdmType[] = [] + @State kfArr: MarkRule[] = [] @State name: string = '' @State idCard: string = '' @State singlePlay: boolean = false; @State totalScore: number = 100 //模拟考试项目 - @State projects: Project[] = [] - @State projectsObj: ProjectObj = {} - @State projectsCenterObj: ProjectObj = {} + @State projects: ProjectInfo[] = [] + @State projectsObj: ProjectInfos = {} + @State projectsCenterObj: ProjectInfo = {} @State markRuleListObj: MarkRule = {} @State cdsbInfoObj: CDSBInfo = {} @State itemInfoObj: CDSBInfo = {} @State timer: number = 0 - @State judgeConfig: CommonType[] = [] + @State judgeConfig: SyssetConfig[] = [] @State judgeConfigObj: object = defaultJudgeConfigObj //流水号 @State lsh: string = '' @@ -103,7 +114,7 @@ struct Index { //监管线路代码 @State xldm: string = '' //监管接口序列号 - @State serialNumber: number = 0 + @State serialNumber: number|string = 0 @State syssetParam623: boolean = false; @State syssetParam211: string = ''; @State carType: string = '' @@ -111,7 +122,7 @@ struct Index { @State isDeductedPopShow: boolean = false @State isAmplifyPopShow: boolean = false @State amplifiedImgIndex: number = 0 - @State judge: any = {} + judge: Judge //行驶距离 @State jl: number = 0 //应考里程 @@ -158,17 +169,17 @@ struct Index { } async aboutToAppear() { - const time = await GetCurrentTime() + const time = GetCurrentTime() this.carInfo = AppStorage.get('carInfo') this.singlePlay = AppStorage.get('singlePlay') this.startTime = time.split(' ')[1] - this.startFullTime = await GetCurrentTime(1); + this.startFullTime = GetCurrentTime(1); // this.startHourTime = await getCurrentHourTime() this.startTime = dayTs().format("HHmmssSSS") this.startExamTime = time setInterval(async () => { - this.time = await GetCurrentTime(); + this.time = GetCurrentTime(); this.examTime += 1; }, 1000); //初始化数据库表 @@ -250,10 +261,10 @@ struct Index { // 获取扣分代码信息 async initMarkRules(markRules ?: MarkRule[]) { - const markRuleParams = markRules || (await GetSyncData('MA_MARKRULE')) + const markRuleParams = markRules || await GetSyncData('MA_MARKRULE') markRuleParams.forEach(mark => { - const tempObj = { + const tempObj:MarkRule = { itemno: mark.itemno * 1, markcatalog: mark.markcatalog, markshow: decodeURI(mark.markshow), @@ -269,10 +280,8 @@ struct Index { if (Number(tempObj.markserial) > 100 && Number(tempObj.markserial) < 200) { this.manualMarkRules.push(tempObj) } - this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = { - ...tempObj, - markserial: mark.markserial, - }; + this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = tempObj + this.markRuleListObj[`${mark.itemno}_${mark.markserial}`].markserial = mark.markserial }) } @@ -280,14 +289,14 @@ struct Index { // 获取sysset表信息 async initSysset(sysset?: SYSSET[]) { - const syssetParams: MASYSSETTableType[] = sysset || await GetSyncData('MA_SYSSET') - const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901'); + 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 = [] + const syssetJudgeConfigArr:SyssetConfig[] = [] - syssetParams.forEach((sys) => { + syssetParams.forEach((sys:SYSSET) => { if (judgeConfig.isTrajectoryOpen) { sys.v_no = sys.key; sys.v_name = sys.name; @@ -295,9 +304,10 @@ struct Index { } // const { v_no, v_value } = sys; - const v_no_num = sys.v_no * 1; + 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) @@ -323,20 +333,22 @@ struct Index { 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 = this.markRuleListObj[`${kf.xmdm}_${kf.kfdm}`]; - const currentProject = this.projectsObj[xmdm] + + const currentKf: MarkRule = Reflect.get(this.markRuleListObj,`${kf.xmdm}_${kf.kfdm}`) + const currentProject:ProjectInfo = Reflect.get(this.projectsObj,kf.xmdm) // 过滤考前绕车一周上车准备的扣分 - if (currentParams.sczb == "1" && xmdm == '1') { + if (currentParams.sczb == "1" && kf.xmdm == '1') { return } this.kfArr.push({ //扣分项目名称 xmmcStr: currentProject.name, - xmdm, + xmdm:kf.xmdm, desc: currentKf.markshow, score: currentKf.markreal, markcatalog: currentKf.markcatalog, @@ -345,10 +357,10 @@ struct Index { }) this.totalScore += currentKf.markreal * 1; }) - this.projectsObj[1].type = kfdm.length ? '4' : '3'; - this.projectsObj = { - ...this.projectsObj - } + const project_1 = Reflect.get(this.projectsObj,1) + project_1.type = kfdm.length ? '4' : '3'; + Reflect.set(this.projectsObj,1,project_1) + } this.judgeConfigObj[sys.v_no] = value @@ -372,7 +384,7 @@ struct Index { console.info('surenjun kStringArr', JSON.stringify(kStringArr)) let isInExam = kStringArr.length > 0; // const { isTrajectoryOpen } = judgeConfig - let carNo = '', allItems = []; + let carNo = '', allItems:string[] = []; systemParms.forEach((systemParm) => { if (judgeConfig.isTrajectoryOpen) { systemParm.no1 = systemParm.NO1 + ''; @@ -385,6 +397,11 @@ struct Index { // 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) { @@ -413,42 +430,36 @@ struct Index { //科目三获取项目 (this.examSubject == "3" && systemParm.no1 == "6") ) { - const name = decodeURI(systemParm.txt1) //小车过滤掉 夜间模拟行驶 if (sCarTypes.includes(this.carType) && name === '夜间行驶') { return } - - const currentProject = { + const currentProject:ProjectInfo = { name, abbreviation: decodeURI(systemParm.txt3), projectCode: no2, projectCodeCenter: txt2, //是否是必考 加减档设置成非必考 - isRequired: no2 == 14 ? false : allItems.includes(no2 + ''), + isRequired: no2 == '14' ? false : allItems.includes(no2 + ''), //是否考过了 isEnd: false, //项目开始数据是否上传过 isUpload: false, } - this.projectsObj[systemParm.no2*1] = currentProject - this.projectsCenterObj[txt2] = currentProject - this.projects.push(currentProject); - + const no2Num = Number(systemParm.no2) //真实监管下发考试项目 if (isInExam && !(kStringArr.includes(txt2) || kStringArr.includes(no2 + ''))) { console.info('surenjun =>', txt2) console.info('surenjun => no2', systemParm.no2) - this.projectsObj[systemParm.no2*1].type = '3' - this.projectsObj[systemParm.no2*1].isUpload = true - this.projectsObj[systemParm.no2*1].isEnd = true - this.projectsCenterObj[txt2].type = '3' - this.projectsCenterObj[txt2].isUpload = true - this.projectsCenterObj[txt2].isEnd = true - // this.isDdxk = true + 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({ @@ -478,10 +489,11 @@ struct Index { //只记录考试项目的模型 const projectsObj = this.projectsObj cdsbParams.forEach((cdsb) => { - const key = decodeURI(cdsb.itemsno); + const key = decodeURI(cdsb.itemsno) const newKey = key.split('~').join('_') - const xmdm = key.split('~')[0] * 1 - if (projectsObj[xmdm]) { + const xmdm = Number( key.split('~')[0] ) + const currentProject:ProjectInfo = Reflect.get(projectsObj, xmdm) + if (currentProject) { this.cdsbInfoObj[newKey] = { kdid: cdsb.kdid, sbbh: cdsb.sbbh, @@ -505,7 +517,8 @@ struct Index { const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist).split(',') || []); const newKey = key.split('~').join('_') const xmdm = Number(key.split('~')[0]) - if (projectsObj[xmdm] && (carlistArr.length == 0 || carlistArr.includes(carlist))) { + const currentProject:ProjectInfo = Reflect.get(projectsObj,xmdm) + if (currentProject && (carlistArr.length == 0 || carlistArr.includes(carlist))) { this.itemInfoObj[newKey] = { modelKey: newKey, xmdm, @@ -518,7 +531,7 @@ struct Index { // 评判相关初始化 async initJudge() { const judge = new Judge(this); - await judge.onJudgeFn(async (judgeData) => { + await judge.onJudgeFn(async (judgeData:JudgeCallBacData) => { // const { xmmcStr, carztStr, kfArr } = judgeData; this.xmmcStr = judgeData.xmmcStr; this.carztStr = judgeData.carztStr; @@ -548,11 +561,14 @@ struct Index { if (ddxkKsxmArr?.length) { //断点续考 ddxkKsxmArr.forEach(xmdm => { - const projectCode = this.projectsCenterObj[xmdm].projectCode - if (this.projectsObj[projectCode]) { - this.projectsObj[projectCode].type = '3' - this.projectsObj[projectCode].isUpload = true - this.projectsObj[projectCode].isEnd = true + 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 @@ -560,16 +576,18 @@ struct Index { } //扣分续考 ddxkKfArr.forEach((kf) => { - const [xmdm, kfdm] = kf.split(',') - const currentKf = this.markRuleListObj[`${xmdm}_${kfdm}`] - const currentProject = this.projectsObj[xmdm] || { name: '通用评判' } - if (this.projectsObj[xmdm]) { - this.projectsObj[xmdm].type = '4' + 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, - xmdm, desc: currentKf.markshow, score: currentKf.markreal, markcatalog: currentKf.markcatalog, @@ -623,17 +641,20 @@ struct Index { // 初始化本地systemparam表、markrule表 async initTrajectoryParam(trajectoryPath: string) { - const { isTrajectoryOpen } = judgeConfig + 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, beginData] = [strArr[0], strArr[1]]; - const initDataObj = JSON.parse(initData) - const beginDataObj = JSON.parse(beginData) + 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 * 1) : examSubject; + this.examSubject = isTrajectoryOpen ? (initDataObj.kskm) : examSubject; this.carInfo.examSubject = this.examSubject this.singlePlay = beginDataObj.exam == 0; this.carName = initDataObj.name; @@ -645,14 +666,14 @@ struct Index { // 上传考试里程 async uploadMileage() { if (!this.singlePlay) { - const { lsh, startExamTime:kskssj, jl:kslc } = this - const { carId, examinationRoomId } = this.carInfo; + const carInfo = this.carInfo + await uploadExamMileage({ - carId, - examinationRoomId, - lsh, - kskssj, - kslc + carId:carInfo.carId, + examinationRoomId:carInfo.examinationRoomId, + lsh:this.lsh, + kskssj:this.startExamTime, + kslc:this.jl }) } } @@ -742,7 +763,7 @@ struct Index { Flex({ direction: FlexDirection.Column }) { if (this.kfArr.length) { List({ scroller: this.kfArrScroller }) { - ForEach(this.kfArr, (item) => { + ForEach(this.kfArr, (item:MarkRule) => { ListItem() { Column() { Row() { @@ -811,7 +832,7 @@ struct Index { if (this.examSubject == "2") { Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { List({}) { - ForEach(chunkArr(this.projects, 2), (item) => { + ForEach(chunkArr(this.projects, 2), (item:[ProjectInfo,ProjectInfo]) => { ListItem() { Row() { Row() { @@ -819,7 +840,7 @@ struct Index { // Text(this.projectsObj[item[0].projectCode]) Text(item[0].abbreviation) .fontSize(item[0].abbreviation.length > 5 ? 28 : 32) - .fontColor(this.getProjectColor(this.projectsObj[item[0].projectCode].type)) + .fontColor(this.getProjectColor(item[0])) } .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) .backgroundImageSize({ width: '100%', height: '100%' }) @@ -833,7 +854,7 @@ struct Index { //#FF7566 #00FFD5 #E6DECF Text(item[1].abbreviation) .fontSize(item[1].abbreviation.length > 5 ? 28 : 32) - .fontColor(this.getProjectColor(this.projectsObj[item[1].projectCode].type)) + .fontColor(this.getProjectColor(item[1])) } .backgroundImage($rawfile('judge/project_item.png'), ImageRepeat.NoRepeat) .backgroundImageSize({ width: '100%', height: '100%' }) @@ -855,7 +876,7 @@ struct Index { .margin({ right: 10 }) } //科目三 - if (this.examSubject == 3) { + if (this.examSubject == '3') { Column() { Flex({ wrap: FlexWrap.Wrap, @@ -863,11 +884,11 @@ struct Index { justifyContent: FlexAlign.SpaceBetween }) { List({}) { - ForEach(this.projects, (project) => { + ForEach(this.projects, (project:ProjectInfo) => { ListItem() { Text(project.name) { } - .fontColor(this.getProjectColor(this.projectsObj[project.projectCode].type)) + .fontColor(this.getProjectColor(project)) .margin({ bottom: 2 }) .fontSize(24) }.margin({ bottom: 2 }) @@ -888,7 +909,7 @@ struct Index { justifyContent: FlexAlign.SpaceAround }) { List() { - ForEach(this.artSubject3Projects, (item, index) => { + ForEach(this.artSubject3Projects, (item:string, index) => { ListItem() { } .backgroundImage( @@ -1042,11 +1063,11 @@ struct Index { //科目三人工扣分弹窗 - if (this.isDeductedPopShow && this.examSubject == 3 && this.judgeConfigObj['342'] == '0') { + if (this.isDeductedPopShow && this.examSubject == '3' && this.judgeConfigObj['342'] == '0') { DeductedPopup({ defaultTabIndex: this.defaultTabIndex, currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { - const project = this.projectsObj[projectKey] + const project:ProjectInfo = Reflect.get(this.projectsObj,projectKey) return project.type == '2' ? project.projectCode : undefined }).filter(project => project !== undefined), markRules: this.manualMarkRules, @@ -1054,7 +1075,7 @@ struct Index { this.isDeductedPopShow = false; this.defaultTabIndex = 0; }, - confirmMark: async (itemno, serial) => { + confirmMark: async (itemno:string, serial:string) => { clearTimeout(this.popTimer) this.popTimer = null this.popTimer = setTimeout(async () => { @@ -1094,10 +1115,10 @@ struct Index { } //科目三人工项目确认框 - if (this.isAmplifyPopShow && this.examSubject == 3) { + if (this.isAmplifyPopShow && this.examSubject == '3') { AmplifyPopup({ amplifyImgIndex: this.amplifiedImgIndex, - confirmAmplify: async (amplify) => { + confirmAmplify: async (amplify:AmplifyItem) => { clearTimeout(this.popTimer) this.popTimer = null this.popTimer = setTimeout(async () => { @@ -1191,7 +1212,8 @@ struct Index { .height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) } - getProjectColor(type: string) { + getProjectColor(project: ProjectInfo) { + const type = project.type; switch (type) { case '1': return '#E6DECF'; @@ -1213,22 +1235,23 @@ struct Index { //人工项目操作 async setManualProjectFn(index: number) { - const { - judgeConfigObj, - isManualProjectIn, - getIsExitManualProject, - artSubject3ProjectsCodesArr, - projectsObj - } = this; - const projectCode = artSubject3ProjectsCodesArr[index]; + + 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 && projectsObj[projectCode].type == '2') { + if (isManualProjectIn && currentProject.type == '2') { //判断人工是否能取消项目 && 当前项目有扣分的不能取消 - if (judgeConfigObj['340'] == 1 && projectsObj[projectCode].type != '5') { + if (judgeConfigObj['340'] == 1) { await this.judge.setJudgeItem(projectCode, 2); Prompt.showToast({ message: '项目取消', @@ -1243,7 +1266,7 @@ struct Index { const xmmcStr = this.xmmcStr; if (xmmcStr == '无' || xmmcStr == '') { //512[6] 人工项目按钮放大确认 - const param512 = (judgeConfigObj['512'] || '').split(','); + const param512:string[] = (judgeConfigObj['512'] || '').split(','); console.info('surenjun', param512) if (param512[6] !== '0') { this.amplifiedImgIndex = index; @@ -1269,33 +1292,34 @@ struct Index { // 获取是否能人工进项目 getIsExitManualProject = (index: number) => { - const { - judgeConfigObj, - artSubject3ProjectsCodesArr, - projectsObj, - carztStr, - isManualProjectIn, - isProjectIn, - getProjectIsInRoad - } = this; + + 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]; - if (projectsObj[projectCode] === undefined) { + const currentProject:ProjectInfo = Reflect.get(projectsObj,projectCode) + if (currentProject === undefined) { return false } - const projectType = projectsObj[projectCode].type; + const projectType = currentProject.type; //不允许人工触发的项目列表,以","分隔 - const unExitManualProjects = judgeConfigObj['332'].split(',') || []; + const unExitManualProjects:string[] = judgeConfigObj['332'].split(',') || []; //直线行驶中不进其他考试项目(0-否 1-是) - const param348 = judgeConfigObj['348'] || '0', + const param348:string = judgeConfigObj['348'] || '0', //里程不够允许手工点靠边停车(0-否 1-是) - param387 = judgeConfigObj['387'] || '0', + param387:string = judgeConfigObj['387'] || '0', //里程不够不报靠边停车(0-否+1-是+2-必考项目未完成且里程不够不报项目) - param319 = judgeConfigObj['319'] || '0', + param319:string = judgeConfigObj['319'] || '0', //人工项目是否能取消 1:可取消; - param340 = judgeConfigObj['340'] || '0', + param340:string = judgeConfigObj['340'] || '0', //307参数里设置的项目,项目已经做过,后续不能人工触发; - param307 = (judgeConfigObj['307'] || '').split(','); + param307:string[] = (judgeConfigObj['307'] || '').split(','); //非行驶状态(没有速度),人工项目不能触发(按钮灰色) if (carztStr === '停车') { @@ -1314,8 +1338,8 @@ struct Index { //项目进行中不能人工触发 if (isProjectIn) { - if (param340 == 1) { - if (isManualProjectIn && (projectsObj[projectCode].type == '2')) { + if (param340 == '1') { + if (isManualProjectIn && (currentProject.type == '2')) { return true } else { return false @@ -1329,8 +1353,9 @@ struct Index { return false } + const project_9:ProjectInfo = Reflect.get(projectsObj,'9') // 直线行驶中不进其他考试项目(0-否 1-是) - if (param348 == '0' && projectsObj['9']?.type == 2) { + if (param348 == '0' && project_9.type == '2') { return index === 0 ? true : false } @@ -1341,7 +1366,9 @@ struct Index { //319不为0,或者387不为1,里程不够时,靠边停车项目不能触发 if ((param387 != '1' || param319 != '0') && index === 5) { - const { examMileage, isRequiredProjectsEnd, jl } = this; + const examMileage = this.examMileage + const isRequiredProjectsEnd = this.isRequiredProjectsEnd + const jl = this.jl //里程是否达标 && 必考项目是否全完成 return jl >= Number(examMileage) && isRequiredProjectsEnd } @@ -1349,37 +1376,46 @@ struct Index { } // 判断项目是否在当前路段号 getProjectIsInRoad = (projectCode: string,) => { - const { - judgeConfigObj, - lane:{ road, num, count } - } = this; + const judgeConfigObj = this.judgeConfigObj; + const lane = this.lane; + const road = lane.road; + const num = lane.num; + const count = lane.count; - const projectRoads = { + const param_3:string[] = (judgeConfigObj['514']?.split(',') || []); + const param_4:string[] = (judgeConfigObj['515']?.split(',') || []); + const param_10:string[] = (judgeConfigObj['516']?.split(',') || []); + const param_11:string[] = (judgeConfigObj['517']?.split(',') || []); + const param_9:string[] = (judgeConfigObj['518']?.split(',') || []); + const param_12:string[] = (judgeConfigObj['519']?.split(',') || []); + + const projectRoads:ProjectRoads = { //直线行驶 - '3': (judgeConfigObj['514']?.split(',') || []), + param_3, //变更车道 - '4': judgeConfigObj['515']?.split(',') || [], + param_4, //超车 - '10': judgeConfigObj['516']?.split(',') || [], + param_10, //靠边停车 - '11': judgeConfigObj['517']?.split(',') || [], + param_11, //会车 - '9': judgeConfigObj['518']?.split(',') || [], + param_9, //掉头 - '12': judgeConfigObj['519']?.split(',') || [], + param_12, }; + //未测绘得道路上或者不在差分状态 if (road === '') { return false } - - if (projectRoads[projectCode].length == 0) { + const currentProjectRoad:string[] = Reflect.get(projectRoads,`param_${projectCode}`) + if (currentProjectRoad.length == 0) { return true } //设置了514-519参数,只能在设置的路段触发对应项目 - if (projectRoads[projectCode].includes(road)) { + if (currentProjectRoad.includes(road)) { //如果525为1,则514-519设置的路段不能触发对应项目 if (judgeConfigObj['525'] == '1') { return false @@ -1410,7 +1446,8 @@ struct Index { getIsEndManualProject = (index: number) => { const projectName = this.artSubject3Projects[index]; const projectCode = this.artSubject3ProjectsCodesArr[index]; - const type = this.projectsObj[projectCode].type + const currentProject:ProjectInfo = Reflect.get(this.projectsObj,projectCode) + const type = currentProject.type if (type == '2') { return projectName } @@ -1418,8 +1455,7 @@ struct Index { } // 获取是否能进行人工评判 getIsManualKf = () => { - const { examSubject } = this; - if (examSubject == 3) { + if (this.examSubject == '3') { //杭州训练模式不允许人工评判 if (this.singlePlay && this.judgeConfigObj['211'] == 'zjhz') { return false diff --git a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts index f398950e..15716eb4 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts @@ -23,9 +23,15 @@ export interface MarkRule { markreal?: number kfxh?: string onlyoneid?: number + OnlyOneKind?: number nocancelid?: number + NoCancelId?: number gps_sid?: number, + GPS_SID?:boolean score?:number + xmmcStr?: string + desc?: string + xmdm?: string } export interface KF{ diff --git a/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts b/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts index aa12a9a4..f7b76e65 100644 --- a/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts +++ b/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts @@ -522,7 +522,7 @@ export const testRealExam = { "zcsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}], "yqsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}], "yhsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}], - "ycsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh": 2,"lx": 2 , "jl": 4.82,"sd": 5.24}], + "ycsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}], "fqsj": [{"bh": 1,"lx": 1,"jl": 2.35,"sd": 3.68}, {"bh":2,"lx": 2 , "jl": 4.82,"sd": 5.24}], "qfwt": {"xrjl": 2.357,"zawjl": 3.608}, "rcyz": 1, diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 3fcd2d85..38bbc819 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -205,12 +205,12 @@ export default class Judge { console.info(judgeTag, `人工扣分-${itemno}-${serial}`) } //人工操作项目 - public setJudgeItem = async (itemno: number, type: 1 | 2) => { + public setJudgeItem = async (itemno: string, type: 1 | 2) => { // const { fileLog } = this; - await examJudgeArtificialItem(itemno * 1, type); + await examJudgeArtificialItem(Number(itemno), type); await this.fileLog.setExamJudgeData({ method: 'examJudgeArtificialItem', - itemno: itemno * 1, + itemno: Number(itemno), type }) console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`)