From 4319805f459b8641c91d4b140c89994179ba2953 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Mon, 31 Mar 2025 10:36:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Judge.ets | 218 ++--- .../src/main/ets/pages/judgeSDK/api/index.ets | 59 +- entry/src/main/ets/pages/judgeSDK/judge.ets | 902 +++++++++--------- .../judgeSDK/utils/voiceAnnouncements.ets | 21 +- 4 files changed, 618 insertions(+), 582 deletions(-) diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 0196a31c..52e96de5 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -10,52 +10,39 @@ 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, - ProjectObj, - SYSTEMPARMARR + 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 { - CarInfoType, - CommonType, - ES_CARINFOType, - KfdmType, - MA_CDSBINFOType, - MA_ITEMINFOType, - MA_MAP_POINT_ITEMType, - MA_MAP_POINTType, - MA_MARKRULEType, - MA_SYSTEMPARMType, - MASYSSETTableType, - RouteParamsType, - User, - SYSSET, - SyssetConfig, - ProjectInfo, - ProjectInfos, - ProjectCenterInfos, - JudgeInitObj, - JudgeBeginObj, - UploadExamMileage, - AmplifyItem, - ProjectRoads, - JudgeCallBacData, - JudgeUI, - CDSBInfos, - ItemInfos, - MarkRules, - DefaultJudgeConfigObj + 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'; @@ -168,23 +155,23 @@ struct Index { @State carInfo: CarInfoType = {} @State isErrorMsgEnd: boolean = false @State disConnectErrorOpen: boolean = false - public context = getContext(this) as common.UIAbilityContext; + public context = getContext(this) as common.UIAbilityContext; async aboutToDisappear() { clearInterval(this.mileageTimer) } async aboutToAppear() { - const time = GetCurrentTime() + const time = GetCurrentTime() this.carInfo = AppStorage.get('carInfo') this.singlePlay = AppStorage.get('singlePlay') this.startTime = time.split(' ')[1] - this.startFullTime = GetCurrentTime(1); + this.startFullTime = GetCurrentTime(1); // this.startHourTime = await getCurrentHourTime() this.startTime = dayTs().format("HHmmssSSS") this.startExamTime = time setInterval(async () => { - this.time = GetCurrentTime(); + this.time = GetCurrentTime(); this.examTime += 1; }, 1000); //初始化数据库表 @@ -251,7 +238,6 @@ struct Index { async initStudent() { const students = await GetSyncData('USER') const stuInfo = students[0]; - // const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl, xldm } = stuInfo; this.name = stuInfo.xm || '测试考生'; this.idCard = stuInfo.sfzmhm || '01234567891010'; this.lsh = this.singlePlay ? '0000000000000' : stuInfo.lsh; @@ -269,7 +255,7 @@ struct Index { const markRuleParams = markRules || await GetSyncData('MA_MARKRULE') markRuleParams.forEach(mark => { - const tempObj:MarkRule = { + const tempObj: MarkRule = { itemno: mark.itemno * 1, markcatalog: mark.markcatalog, markshow: decodeURI(mark.markshow), @@ -299,9 +285,9 @@ struct Index { console.info('surenjun serialNumberArr' + JSON.stringify(serialNumberArr)) this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || ''; // const { isTrajectoryOpen } = judgeConfig - const syssetJudgeConfigArr:SyssetConfig[] = [] + const syssetJudgeConfigArr: SyssetConfig[] = [] - syssetParams.forEach((sys:SYSSET) => { + syssetParams.forEach((sys: SYSSET) => { if (judgeConfig.isTrajectoryOpen) { sys.v_no = String(sys.key); sys.v_name = sys.name; @@ -309,7 +295,7 @@ struct Index { } // const { v_no, v_value } = sys; - const v_no_num = Number(sys.v_no) + 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 = @@ -342,8 +328,8 @@ struct Index { 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) + 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) { @@ -353,7 +339,7 @@ struct Index { this.kfArr.push({ //扣分项目名称 xmmcStr: currentProject.name, - xmdm:kf.xmdm, + xmdm: kf.xmdm, desc: currentKf.markshow, score: currentKf.markreal, markcatalog: currentKf.markcatalog, @@ -362,9 +348,9 @@ struct Index { }) 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) + 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) @@ -388,7 +374,7 @@ struct Index { console.info('surenjun kStringArr', JSON.stringify(kStringArr)) let isInExam = kStringArr.length > 0; // const { isTrajectoryOpen } = judgeConfig - let carNo = '', allItems:string[] = []; + let carNo = '', allItems: string[] = []; systemParms.forEach((systemParm) => { if (judgeConfig.isTrajectoryOpen) { systemParm.no1 = systemParm.NO1 + ''; @@ -439,7 +425,7 @@ struct Index { if (sCarTypes.includes(this.carType) && name === '夜间行驶') { return } - const currentProject:ProjectInfo = { + const currentProject: ProjectInfo = { name, abbreviation: decodeURI(systemParm.txt3), projectCode: no2, @@ -495,10 +481,10 @@ struct Index { 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) + const xmdm = Number(key.split('~')[0]) + const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) if (currentProject) { - const cdsbInfo:CDSBInfo = { + const cdsbInfo: CDSBInfo = { kdid: cdsb.kdid, sbbh: cdsb.sbbh, sbbm: cdsb.sbbm, @@ -522,9 +508,9 @@ struct Index { 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) + const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) if (currentProject && (carlistArr.length == 0 || carlistArr.includes(carlist))) { - Reflect.set(this.itemInfoObj,newKey, { + Reflect.set(this.itemInfoObj, newKey, { modelKey: newKey, xmdm, xmxh: key.split('~')[1], @@ -535,10 +521,10 @@ struct Index { // 评判相关初始化 async initJudge() { - const JUDGEUI:JudgeUI = this; + const JUDGEUI: JudgeUI = this; const judge = new Judge(JUDGEUI); // await judge.init() - await judge.onJudgeFn(async (judgeData:JudgeCallBacData) => { + await judge.onJudgeFn(async (judgeData: JudgeCallBacData) => { // const { xmmcStr, carztStr, kfArr } = judgeData; this.xmmcStr = judgeData.xmmcStr; this.carztStr = judgeData.carztStr; @@ -551,7 +537,7 @@ struct Index { async goDdxkItems() { const judgeConfigObj = this.judgeConfigObj - const config_432:string = Reflect.get(judgeConfigObj,'432') + const config_432: string = Reflect.get(judgeConfigObj, '432') //科目二强制开始断点续考 if (config_432 != '0' || this.examSubject == "2") { //断点续考判断 @@ -569,9 +555,9 @@ struct Index { if (ddxkKsxmArr?.length) { //断点续考 ddxkKsxmArr.forEach(xmdm => { - const currentProjectCenter:Project = Reflect.get(this.projectsCenterObj, xmdm) + const currentProjectCenter: Project = Reflect.get(this.projectsCenterObj, xmdm) const projectCode = currentProjectCenter.projectCode - const currentProject:Project = Reflect.get(this.projectsObj,projectCode) + const currentProject: Project = Reflect.get(this.projectsObj, projectCode) if (currentProject) { currentProject.type = '3' currentProject.isUpload = true @@ -586,8 +572,8 @@ struct Index { 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: '通用评判' } + const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${xmdm}_${kfdm}`) + const currentProject: ProjectInfo = Reflect.get(this.projectsObj, xmdm) || { name: '通用评判' } if (currentProject) { currentProject.type = '4' @@ -658,11 +644,11 @@ struct Index { const initData = strArr[0] const beginData = strArr[1] - const initDataObj:JudgeInitObj = JSON.parse(initData) - const beginDataObj:JudgeBeginObj = JSON.parse(beginData) + const initDataObj: JudgeInitObj = JSON.parse(initData) + const beginDataObj: JudgeBeginObj = JSON.parse(beginData) const examSubject = this.carInfo.examSubject; - this.examSubject =( isTrajectoryOpen ? (initDataObj.kskm) : examSubject) +''; + this.examSubject = (isTrajectoryOpen ? (initDataObj.kskm) : examSubject) + ''; this.carInfo.examSubject = this.examSubject this.singlePlay = beginDataObj.exam == 0; this.carName = initDataObj.name; @@ -677,11 +663,11 @@ struct Index { const carInfo = this.carInfo await uploadExamMileage({ - carId:carInfo.carId, - examinationRoomId:carInfo.examinationRoomId, - lsh:this.lsh, - kskssj:this.startExamTime, - kslc:this.jl + carId: carInfo.carId, + examinationRoomId: carInfo.examinationRoomId, + lsh: this.lsh, + kskssj: this.startExamTime, + kslc: this.jl }) } } @@ -744,7 +730,7 @@ struct Index { if (this.examSubject == "3") { Row() { - if (Reflect.get(this.judgeConfigObj,'375') == '0') { + if (Reflect.get(this.judgeConfigObj, '375') == '0') { Text(`应行驶:${this.examMileage}m`) .fontColor('#E5CCA1') .fontSize(this.FONTSIZE) @@ -761,7 +747,7 @@ struct Index { Column() { Row() { Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE) - if (Reflect.get(this.judgeConfigObj,'342') == '0') { + if (Reflect.get(this.judgeConfigObj, '342') == '0') { Text(`${this.dw}挡`).fontColor('#FFA500').fontSize(this.FONTSIZE).padding({ left: 15, right: 15 }) Text(`${this.sd}km/h`).fontColor('#FFA500').fontSize(this.FONTSIZE) } @@ -771,7 +757,7 @@ struct Index { Flex({ direction: FlexDirection.Column }) { if (this.kfArr.length) { List({ scroller: this.kfArrScroller }) { - ForEach(this.kfArr, (item:MarkRule) => { + ForEach(this.kfArr, (item: MarkRule) => { ListItem() { Column() { Row() { @@ -840,7 +826,7 @@ struct Index { if (this.examSubject == "2") { Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { List({}) { - ForEach(chunkArr(this.projects, 2), (item:[ProjectInfo,ProjectInfo]) => { + ForEach(chunkArr(this.projects, 2), (item: [ProjectInfo, ProjectInfo]) => { ListItem() { Row() { Row() { @@ -892,7 +878,7 @@ struct Index { justifyContent: FlexAlign.SpaceBetween }) { List({}) { - ForEach(this.projects, (project:ProjectInfo) => { + ForEach(this.projects, (project: ProjectInfo) => { ListItem() { Text(project.name) { } @@ -917,7 +903,7 @@ struct Index { justifyContent: FlexAlign.SpaceAround }) { List() { - ForEach(this.artSubject3Projects, (item:string, index) => { + ForEach(this.artSubject3Projects, (item: string, index) => { ListItem() { } .backgroundImage( @@ -1042,7 +1028,7 @@ struct Index { // type: 1, // name: 'button_media.wav' // }) - if (Reflect.get(this.judgeConfigObj,'353') == '0') { + if (Reflect.get(this.judgeConfigObj, '353') == '0') { this.endPopupVisible = true } else { Prompt.showToast({ @@ -1071,11 +1057,11 @@ struct Index { //科目三人工扣分弹窗 - if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj,'342') == '0') { + if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj, '342') == '0') { DeductedPopup({ defaultTabIndex: this.defaultTabIndex, currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => { - const project:ProjectInfo = Reflect.get(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, @@ -1083,7 +1069,7 @@ struct Index { this.isDeductedPopShow = false; this.defaultTabIndex = 0; }, - confirmMark: async (itemno:string, serial:string) => { + confirmMark: async (itemno: string, serial: string) => { clearTimeout(this.popTimer) this.popTimer = null this.popTimer = setTimeout(async () => { @@ -1126,7 +1112,7 @@ struct Index { if (this.isAmplifyPopShow && this.examSubject == '3') { AmplifyPopup({ amplifyImgIndex: this.amplifiedImgIndex, - confirmAmplify: async (amplify:AmplifyItem) => { + confirmAmplify: async (amplify: AmplifyItem) => { clearTimeout(this.popTimer) this.popTimer = null this.popTimer = setTimeout(async () => { @@ -1155,7 +1141,7 @@ struct Index { router.back() return } - if (Reflect.get(this.judgeConfigObj,'344') == 1) { + if (Reflect.get(this.judgeConfigObj, '344') == 1) { Prompt.showToast({ message: '考试未结束,不允许手动退出!', duration: 4000 @@ -1221,7 +1207,7 @@ struct Index { } getProjectColor(project: ProjectInfo) { - const type = project.type; + const type = project.type; switch (type) { case '1': return '#E6DECF'; @@ -1250,16 +1236,16 @@ struct Index { const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr; const projectsObj = this.projectsObj; - const projectCode = Reflect.get(artSubject3ProjectsCodesArr,index) + const projectCode = Reflect.get(artSubject3ProjectsCodesArr, index) if (index === 5) { console.info('surenjun 靠边停车状态=> ', getIsExitManualProject(index)) } - const currentProject:ProjectInfo = Reflect.get(projectsObj,projectCode) + const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode) if (getIsExitManualProject(index)) { // 正在进行的项目 取消项目 if (isManualProjectIn && currentProject.type == '2') { //判断人工是否能取消项目 && 当前项目有扣分的不能取消 - if (Reflect.get(this.judgeConfigObj,'340') == 1) { + if (Reflect.get(this.judgeConfigObj, '340') == 1) { await this.judge.setJudgeItem(projectCode, 2); Prompt.showToast({ message: '项目取消', @@ -1270,11 +1256,11 @@ struct Index { } // 靠边停车时候可以触发 - if (Reflect.get(this.judgeConfigObj,'343') === '0') { + 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(','); + const param512: string[] = (Reflect.get(this.judgeConfigObj, '512') || '').split(','); console.info('surenjun', param512) if (param512[6] !== '0') { this.amplifiedImgIndex = index; @@ -1310,24 +1296,24 @@ struct Index { const getProjectIsInRoad = this.getProjectIsInRoad; const projectCode = artSubject3ProjectsCodesArr[index]; - const currentProject:ProjectInfo = Reflect.get(projectsObj,projectCode) + 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(',') || []; + const unExitManualProjects: string[] = Reflect.get(this.judgeConfigObj, '332').split(',') || []; //直线行驶中不进其他考试项目(0-否 1-是) - const param348:string = Reflect.get(this.judgeConfigObj,'348') || '0', + const param348: string = Reflect.get(this.judgeConfigObj, '348') || '0', //里程不够允许手工点靠边停车(0-否 1-是) - param387:string = Reflect.get(this.judgeConfigObj,'387') || '0', + param387: string = Reflect.get(this.judgeConfigObj, '387') || '0', //里程不够不报靠边停车(0-否+1-是+2-必考项目未完成且里程不够不报项目) - param319:string = Reflect.get(this.judgeConfigObj,'319') || '0', + param319: string = Reflect.get(this.judgeConfigObj, '319') || '0', //人工项目是否能取消 1:可取消; - param340:string = Reflect.get(this.judgeConfigObj,'340') || '0', + param340: string = Reflect.get(this.judgeConfigObj, '340') || '0', //307参数里设置的项目,项目已经做过,后续不能人工触发; - param307:string[] = (Reflect.get(this.judgeConfigObj,'307') || '').split(','); + param307: string[] = (Reflect.get(this.judgeConfigObj, '307') || '').split(','); //非行驶状态(没有速度),人工项目不能触发(按钮灰色) if (carztStr === '停车') { @@ -1335,7 +1321,7 @@ struct Index { } //车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能) - if (Reflect.get(this.judgeConfigObj,'342') === '3' || Reflect.get(this.judgeConfigObj,'342') === '2') { + if (Reflect.get(this.judgeConfigObj, '342') === '3' || Reflect.get(this.judgeConfigObj, '342') === '2') { return false } @@ -1361,7 +1347,7 @@ struct Index { return false } - const project_9:ProjectInfo = Reflect.get(projectsObj,'9') + const project_9: ProjectInfo = Reflect.get(projectsObj, '9') // 直线行驶中不进其他考试项目(0-否 1-是) if (param348 == '0' && project_9.type == '2') { return index === 0 ? true : false @@ -1390,14 +1376,14 @@ struct Index { 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 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 = { + const projectRoads: ProjectRoads = { //直线行驶 param_3, //变更车道 @@ -1417,7 +1403,7 @@ struct Index { if (road === '') { return false } - const currentProjectRoad:string[] = Reflect.get(projectRoads,`param_${projectCode}`) + const currentProjectRoad: string[] = Reflect.get(projectRoads, `param_${projectCode}`) if (currentProjectRoad.length == 0) { return true } @@ -1425,7 +1411,7 @@ struct Index { //设置了514-519参数,只能在设置的路段触发对应项目 if (currentProjectRoad.includes(road)) { //如果525为1,则514-519设置的路段不能触发对应项目 - if (Reflect.get(this.judgeConfigObj,'525') == '1') { + if (Reflect.get(this.judgeConfigObj, '525') == '1') { return false } } else { @@ -1434,7 +1420,7 @@ struct Index { //405参数为2是,如果在最左侧车道,超车项目不能触发; if (projectCode == '10' && - Reflect.get(this.judgeConfigObj,'405') == '2' && + Reflect.get(this.judgeConfigObj, '405') == '2' && (num === count) && num > 0 ) { @@ -1454,7 +1440,7 @@ struct Index { getIsEndManualProject = (index: number) => { const projectName = this.artSubject3Projects[index]; const projectCode = this.artSubject3ProjectsCodesArr[index]; - const currentProject:ProjectInfo = Reflect.get(this.projectsObj,projectCode) + const currentProject: ProjectInfo = Reflect.get(this.projectsObj, projectCode) const type = currentProject.type if (type == '2') { return projectName @@ -1465,10 +1451,10 @@ struct Index { getIsManualKf = () => { if (this.examSubject == '3') { //杭州训练模式不允许人工评判 - if (this.singlePlay && Reflect.get(this.judgeConfigObj,'211') == 'zjhz') { + if (this.singlePlay && Reflect.get(this.judgeConfigObj, '211') == 'zjhz') { return false } - if (Reflect.get(this.judgeConfigObj,'342') == '0') { + if (Reflect.get(this.judgeConfigObj, '342') == '0') { return true } } else { diff --git a/entry/src/main/ets/pages/judgeSDK/api/index.ets b/entry/src/main/ets/pages/judgeSDK/api/index.ets index 4642c59e..7b0ba8d0 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/index.ets +++ b/entry/src/main/ets/pages/judgeSDK/api/index.ets @@ -1,4 +1,5 @@ -import libJudgeSdk from "libjudgesdk.so" +import libJudgeSdk from 'libjudgesdk.so'; +import { JudgeInitObj } from '../../../model'; // import libJudgeSdk from '@ohos.judgesdk' /** @@ -24,8 +25,8 @@ export async function examJudgeVersion(): Promise { * @params callBack 日志操作回调 * @desc 设置评判日志级别和日志回调函数 */ -export async function examJudgeSetLogCallback(level: number, handleLog: Function): Promise { - const temp:number = libJudgeSdk.examJudgeSetLogCallback(level, handleLog); +export async function examJudgeSetLogCallback(level: number, handleLog: Function): Promise { + const temp: number = libJudgeSdk.examJudgeSetLogCallback(level, handleLog); return await handle(temp, 'examJudgeSetLogCallback') } @@ -33,9 +34,9 @@ export async function examJudgeSetLogCallback(level: number, handleLog: Function * * @desc评判初始化 */ -export async function examJudgeInit(data) { +export async function examJudgeInit(data: JudgeInitObj) { const str = JSON.stringify(data); - const temp:number = libJudgeSdk.examJudgeInit(str, str.length); + const temp: number = libJudgeSdk.examJudgeInit(str, str.length); return await handle(temp, 'examJudgeInit') } @@ -44,7 +45,7 @@ export async function examJudgeInit(data) { * @desc 执行实时考试过程 实时传递传感信息 */ export async function examJudgeRealExam(data) { - const temp:number = libJudgeSdk.examJudgeRealExam(JSON.stringify(data), str.length); + const temp: number = libJudgeSdk.examJudgeRealExam(JSON.stringify(data), str.length); return await handle(temp, 'examJudgeRealExam') } @@ -53,8 +54,8 @@ export async function examJudgeRealExam(data) { * @desc 设置评判输出的考试过程数据回调函数 */ //js_examJudgeSetRealExamCallback -export async function examJudgeSetRealExamCallback(fn:Function) { - const temp:number = libJudgeSdk.examJudgeSetRealExamCallback(fn); +export async function examJudgeSetRealExamCallback(fn: Function) { + const temp: number = libJudgeSdk.examJudgeSetRealExamCallback(fn); return await handle(temp, 'examJudgeSetRealExamCallback') } @@ -62,8 +63,8 @@ export async function examJudgeSetRealExamCallback(fn:Function) { * * @desc 设置轨迹图像回调函数 */ -export async function examJudgeMapImageSetCallback(fn:Function) { - const temp:number = libJudgeSdk.examJudgeMapImageSetCallback(fn); +export async function examJudgeMapImageSetCallback(fn: Function) { + const temp: number = libJudgeSdk.examJudgeMapImageSetCallback(fn); return await handle(temp, 'examJudgeMapImageSetCallback') } @@ -80,7 +81,7 @@ export async function examJudgeArtificialMark( //扣分类型:number type: number ) { - const temp:number= libJudgeSdk.examJudgeArtificialMark(itemno, serial, type); + const temp: number = libJudgeSdk.examJudgeArtificialMark(itemno, serial, type); return await handle(temp, 'examJudgeArtificialMark') } @@ -94,7 +95,7 @@ export async function examJudgeArtificialItem( //操作类型 type: number = 0 ) { - const temp:number = libJudgeSdk.examJudgeArtificialItem(itemno, type); + const temp: number = libJudgeSdk.examJudgeArtificialItem(itemno, type); return await handle(temp, 'examJudgeArtificialMark') } @@ -103,8 +104,8 @@ export async function examJudgeArtificialItem( * * @desc 设置地图轨迹图像绘制的开关 */ -export async function examJudgeMapSetDrawing(bool:boolean) { - const temp:number = libJudgeSdk.examJudgeMapSetDrawing(bool); +export async function examJudgeMapSetDrawing(bool: boolean) { + const temp: number = libJudgeSdk.examJudgeMapSetDrawing(bool); return await handle(temp, 'examJudgeMapSetDrawing') } @@ -115,7 +116,7 @@ export async function examJudgeMapSetDrawing(bool:boolean) { */ export async function examJudgeBeginExam(data) { const str = JSON.stringify(data); - const temp:number = libJudgeSdk.examJudgeBeginExam(str, str.length); + const temp: number = libJudgeSdk.examJudgeBeginExam(str, str.length); return await handle(temp, 'examJudgeBeginExam') } @@ -132,7 +133,7 @@ export async function examJudgeBeginExam(data) { * */ export async function examJudgeEndExam() { - const temp:number = libJudgeSdk.examJudgeEndExam(); + const temp: number = libJudgeSdk.examJudgeEndExam(); return await handle(temp, 'examJudgeEndExam') } @@ -141,7 +142,7 @@ export async function examJudgeEndExam() { * */ export async function examJudgeDestroy() { - const temp:number = libJudgeSdk.examJudgeDestroy(); + const temp: number = libJudgeSdk.examJudgeDestroy(); return await handle(temp, 'examJudgeDestroy') } @@ -150,7 +151,7 @@ export async function examJudgeDestroy() { * */ export async function examJudgeMapSetParam(width: number, height: number) { - const temp:number = libJudgeSdk.examJudgeMapSetParam(width, height); + const temp: number = libJudgeSdk.examJudgeMapSetParam(width, height); return await handle(temp, 'examJudgeMapSetParam') } @@ -159,7 +160,7 @@ export async function examJudgeMapSetParam(width: number, height: number) { * */ export async function examJudgeMapSetScaling(scaling?: number) { - const temp:number = libJudgeSdk.examJudgeMapSetScaling(scaling || 1); + const temp: number = libJudgeSdk.examJudgeMapSetScaling(scaling || 1); return await handle(temp, 'examJudgeMapSetScaling') } @@ -168,7 +169,7 @@ export async function examJudgeMapSetScaling(scaling?: number) { * */ export async function examJudgeSetPerformCallback(fn) { - const temp:number = libJudgeSdk.examJudgeSetPerformCallback(fn); + const temp: number = libJudgeSdk.examJudgeSetPerformCallback(fn); return await handle(temp, 'examJudgeSetPerformCallback') } @@ -177,16 +178,19 @@ export async function examJudgeSetPerformCallback(fn) { * @desc 语音播报结束 * / */ -interface SoundParam{ +interface SoundParam { //项目代码 xmdm: number, + //语音码 code: string, + //语音类型 - type: 0|1, + type: 0 | 1, } + export async function examJudgeSoundEnd(param: SoundParam) { - const temp:number = libJudgeSdk.examJudgeSoundEnd(param.xmdm, param.code, param.type); + const temp: number = libJudgeSdk.examJudgeSoundEnd(param.xmdm, param.code, param.type); return await handle(temp, 'examJudgeSoundEnd') } @@ -195,15 +199,16 @@ export async function examJudgeSoundEnd(param: SoundParam) { * @desc 实时距离计算 * * */ -interface DistanceParam{ +interface DistanceParam { jd1: number, wd1: number, jd2: number, wd2: number, h: number } -export async function examCalcGpsDistance(param:DistanceParam):Promise { - const temp:number = libJudgeSdk.examCalcGpsDistance(param.jd1, param.wd1, param.jd2, param.wd2, param.h); + +export async function examCalcGpsDistance(param: DistanceParam): Promise { + const temp: number = libJudgeSdk.examCalcGpsDistance(param.jd1, param.wd1, param.jd2, param.wd2, param.h); return temp } @@ -212,7 +217,7 @@ export async function examCalcGpsDistance(param:DistanceParam):Promise { * @desc通用处理函数 * */ -async function handle(temp:number, fnName:string): Promise { +async function handle(temp: number, fnName: string): Promise { return new Promise((resolve, reject) => { if (temp == 0) { resolve(temp); diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 79e385e0..7907997f 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -2,79 +2,190 @@ import systemTime from '@ohos.systemDateTime'; import router from '@ohos.router'; import util from '@ohos.util'; import buffer from '@ohos.buffer'; -import { testKm2Items, testKm3Items, testMarkRules } from './dataTest/index'; -import { EXAMDATA, KSJS, Project, SOUND } from './api/judgeSDK'; +import { testKm2Items, testKm3Items } from './dataTest/index'; +import { KSJS } from './api/judgeSDK'; import VoiceAnnounce from './utils/voiceAnnouncements'; 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 { KF, LANE } from '../judgeSDK/api/judgeSDK.d'; -import { GetSyncData,SqlInsertTable } from '../../utils/table/Operation'; +import { LANE } from '../judgeSDK/api/judgeSDK.d'; +import { GetSyncData, SqlInsertTable } from '../../utils/table/Operation'; import { - getCarStatus, - getCarStatusType, - getCenterProjectStatus, - getDwStatusType, - getKmProjectCancelVoice, - getKmProjectVoice, - getTranslateSignals, - plcStrToJson, - plcStrToWXJson, - promptWxCode, - senorToWXDataStr + getCarStatus, getCenterProjectStatus, plcStrToJson, + plcStrToWXJson, + promptWxCode } from './utils/judgeCommon'; import { - examCalcGpsDistance, - examJudgeArtificialItem, - examJudgeArtificialMark, - examJudgeBeginExam, - examJudgeEndExam, - examJudgeInit, - examJudgeRealExam, - examJudgeSetLogCallback, - examJudgeSetPerformCallback, - examJudgeSetRealExamCallback, - examJudgeSoundEnd, - examJudgeVersion + examCalcGpsDistance, + examJudgeArtificialItem, + examJudgeArtificialMark, + examJudgeBeginExam, + examJudgeEndExam, + examJudgeInit, + examJudgeRealExam, + examJudgeSetLogCallback, + examJudgeSetPerformCallback, + examJudgeSetRealExamCallback, + examJudgeSoundEnd, + examJudgeVersion } from './api/index'; -import { writeObjectOut, uploadExamProgressData } from '../../api/judge'; -import { saveStartRecordVideo,endRecordVideo } from '../../utils/Video'; +import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; +import { endRecordVideo, saveStartRecordVideo } from '../../utils/Video'; import common from '@ohos.app.ability.common'; -import { Array2Byte, convertGpsCoord2, deepClone, fillZero, string2Bytes } from './utils/Common'; -import { GetCurrentTime, StringToASCII } from '../../utils/Common'; +import { convertGpsCoord2, deepClone } from './utils/Common'; +import { GetCurrentTime } from '../../utils/Common'; import UsbService from '../../utils/USB'; import FileUtils from '../../utils/FileUtils'; -import { BaseInfoType, CarInfoType, JudgeUI, Km3JudgeInitConfig ,ProjectInfo,Plc,DistanceClass,Ksjs,MarkRule,RegulatoryInterfaceParams,DrvexamType,RecordHandleType,WR,CDSBInfo,ItemInfo,JudgeInitObj,RouteParamsType,ExaminerInfoType,JudgeBeginObj,JudgeKsxm,JudgeKfxm,JudgeSound,JudgeSoundB,JudgeEventKf,JudgeKsjs,JudgeXmjs,JudgeCallBackData,KmItems,KmItem, - JudgeConfigObj,User,TKmItem,JudgePerformInfo,JudgeUdpKf} from '../../model'; +import { + BaseInfoType, + CarInfoType, + CDSBInfo, + DistanceClass, + DrvexamType, + ExaminerInfoType, + ItemInfo, + JudgeBeginObj, + JudgeCallBackData, + JudgeConfigObj, + JudgeEventKf, + JudgeInitObj, + JudgeKfxm, + JudgeKsjs, + JudgeKsxm, + JudgePerformInfo, + JudgeSound, JudgeUI, + JudgeXmjs, + Km3JudgeInitConfig, + KmItem, + KmItems, MarkRule, + Plc, + ProjectInfo, + RecordHandleType, + RegulatoryInterfaceParams, + RouteParamsType, + TKmItem, + User, + WR +} from '../../model'; const judgeTag = 'SURENJUN_JUDGE' -type GetKm3JudgeInitConfig = ()=> Promise -type GetgSbbm = (ksxm:number, xmxh:string) => string -type SendWriteObjectOut = (data:RegulatoryInterfaceParams, filePath:string) => Promise -type GetKfStr = (code:string) => MarkRule -type GetDqxmStr = (xmdm:number) => string +type GetKm3JudgeInitConfig = () => Promise +type GetgSbbm = (ksxm: number, xmxh: string) => string +type SendWriteObjectOut = (data: RegulatoryInterfaceParams, filePath: string) => Promise +type GetKfStr = (code: string) => MarkRule +type GetDqxmStr = (xmdm: number) => string type TJudgeBeginObj = JudgeBeginObj + export default class Judge { - // 断网数据补传 - uploadDisConnectData = async () => { - if (!this.isJudgeDisConnect) { - return - } - const folderPath = this.fileLog.folderPath - const examDataStr = await this.fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`); - const examDataArr = examDataStr.split('\n'); - for (let examDataStr of examDataArr) { - const code = await writeObjectOut(JSON.parse(examDataStr)); + public plcStr: string + public judgeUI: JudgeUI + //获取科目三的评判初始化配置 + getKm3JudgeInitConfig: GetKm3JudgeInitConfig = async () => { + return { + map_point: this.judgeUI.mapPointArr, + map_point_item: this.judgeUI.mapPointItemArr, + //科目三暂时为空 + iteminfo: [], + roads: this.getModelData('km3/Roads.txt'), + sharps: this.getModelData('km3/Sharps.txt') } } + private context: common.UIAbilityContext + private fileLog: FileLog + //人工扣分 + public setJudgeMark = async (itemno: string, serial: string, type = 1) => { + await examJudgeArtificialMark(Number(itemno), serial, type); + console.info(judgeTag, `进入人工扣分-${itemno}-${serial}`) + const str = JSON.stringify({ + method: 'examJudgeArtificialMark', + itemno: Number(itemno), + serial, + type + }) + await this.fileLog.setExamJudgeData(str) + console.info(judgeTag, `人工扣分-${itemno}-${serial}`) + } + //人工操作项目 + public setJudgeItem = async (itemno: string, type: 1 | 2) => { + // const { fileLog } = this; + await examJudgeArtificialItem(Number(itemno), type); + const str = JSON.stringify({ + method: 'examJudgeArtificialItem', + itemno: Number(itemno), + type + }) + await this.fileLog.setExamJudgeData(str) + console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`) + } + private filePath: string + private totalScore: number + private prevJd: number = 0 + private prevWd: number = 0 + private dwztNum: number = 0 + private folderPath: string + private modelPath: string + private avPlayer: VoiceAnnounce + // 处理特殊参数配置 + handleSEP = async (code: number) => { + const judgeConfigObj = this.judgeUI.judgeConfigObj + const avPlayer = this.avPlayer + switch (code) { + //结束考试方式 + case 306: + if (judgeConfigObj[code] == 5) { + //靠边停车 + avPlayer.playAudio(['voice/406001.mp3']) + } + break; + } + } + private carztStr: string + private rmndg: 0 | 1 + private mndgStr: string | undefined + // 模拟灯光 + setMndg = async (mndgStr: string) => { + this.mndgStr = mndgStr + } + private xmmcStr: string + private xmmcCode: string + private xmmcSingleCode: string + private xmmcEndCode?: string + private xmdm: string | number + private xmxh: string + private fileModel: FileModel + private filePhoto: FilePhoto + // 过程照片拍照 + getPhoto = async (empty?: boolean) => { + const singlePlay: boolean = AppStorage.get('singlePlay') + //单机模式返回空照片 + if (singlePlay) { + return '' + } else { + const photoBase64 = await this.filePhoto.getPhoto(); + console.info(judgeTag, '拍照完成') + return photoBase64 + } + } + private usbService: UsbService + //是否是考试模式 + private isExam: boolean + //考试是否结束了 + private isExamEnd: boolean + // 是否发送udp + private isUdpEnd: boolean = false + //是否手动结束考试 + private isManual: boolean + //UDP服务序列号 + private serialIndex: number + private fileUtil: FileUtils //上传无锡所过程数据 uploadProgressData = async () => { const carInfo = AppStorage.get('carInfo') @@ -116,43 +227,16 @@ export default class Judge { } console.info(judgeTag, '过程数据文件上传 end') } - //获取科目三的评判初始化配置 - getKm3JudgeInitConfig:GetKm3JudgeInitConfig = async () => { - return { - map_point: this.judgeUI.mapPointArr, - map_point_item: this.judgeUI.mapPointItemArr, - //科目三暂时为空 - iteminfo: [], - roads: this.getModelData('km3/Roads.txt'), - sharps: this.getModelData('km3/Sharps.txt') - } - } - // 处理特殊参数配置 - handleSEP = async (code: number) => { - const judgeConfigObj = this.judgeUI.judgeConfigObj - const avPlayer = this.avPlayer - switch (code) { - //结束考试方式 - case 306: - if (judgeConfigObj[code] == 5) { - //靠边停车 - avPlayer.playAudio(['voice/406001.mp3']) - } - break; - } - } - public plcStr: string - private context: common.UIAbilityContext - public judgeUI: JudgeUI + private judgeTask: JudgeTask // 检测扣分、结束项目时该项目是否开始 - checkProjectIsStart = async (xmdm:number, currentType: 1 | 2, kf?: JudgeEventKf) => { + checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: JudgeEventKf) => { if (xmdm == 20) { return true } - const judgeUI= this.judgeUI; - const judgeTask= this.judgeTask; + const judgeUI = this.judgeUI; + const judgeTask = this.judgeTask; const projectsObj = this.judgeUI.projectsObj - const currentProject:ProjectInfo = Reflect.get(projectsObj, xmdm) + const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) const isUpload = currentProject.isUpload //如果项目没有开始 @@ -171,7 +255,7 @@ export default class Judge { isDelay: true }) currentProject.isUpload = true; - Reflect.set(this.judgeUI.projectsObj,xmdm,currentProject) + Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) //扣分补传 if (currentType == 2) { judgeTask.addTask(async () => { @@ -188,7 +272,7 @@ export default class Judge { isDelay: true }) currentProject.isEnd = true; - Reflect.set(this.judgeUI.projectsObj,xmdm,currentProject) + Reflect.set(this.judgeUI.projectsObj, xmdm, currentProject) } judgeTask.addTask(async () => { this.checkExamIsEnd() @@ -198,82 +282,6 @@ export default class Judge { return true } } - private fileLog: FileLog - - //人工扣分 - public setJudgeMark = async (itemno:string, serial:string, type = 1) => { - await examJudgeArtificialMark(Number(itemno), serial, type); - console.info(judgeTag, `进入人工扣分-${itemno}-${serial}`) - const str = JSON.stringify({ - method: 'examJudgeArtificialMark', - itemno: Number(itemno), - serial, - type - }) - await this.fileLog.setExamJudgeData(str) - console.info(judgeTag, `人工扣分-${itemno}-${serial}`) - } - - //人工操作项目 - public setJudgeItem = async (itemno: string, type: 1 | 2) => { - // const { fileLog } = this; - await examJudgeArtificialItem(Number(itemno), type); - const str = JSON.stringify({ - method: 'examJudgeArtificialItem', - itemno: Number(itemno), - type - }) - await this.fileLog.setExamJudgeData(str) - console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`) - } - private filePath: string - private totalScore: number - private prevJd: number = 0 - private prevWd: number = 0 - private dwztNum: number = 0 - private folderPath: string - private modelPath: string - private avPlayer: VoiceAnnounce - private carztStr: string - private rmndg: 0 | 1 - private mndgStr: string | undefined - // 模拟灯光 - setMndg = async (mndgStr: string) => { - this.mndgStr = mndgStr - } - private xmmcStr: string - private xmmcCode: string - private xmmcSingleCode: string - private xmmcEndCode?: string - private xmdm: string | number - private xmxh: string - private fileModel: FileModel - private filePhoto: FilePhoto - // 过程照片拍照 - getPhoto = async (empty?: boolean) => { - const singlePlay: boolean = AppStorage.get('singlePlay') - //单机模式返回空照片 - if (singlePlay) { - return '' - } else { - const photoBase64 = await this.filePhoto.getPhoto(); - console.info(judgeTag, '拍照完成') - return photoBase64 - } - } - private usbService: UsbService - //是否是考试模式 - private isExam: boolean - //考试是否结束了 - private isExamEnd: boolean - // 是否发送udp - private isUdpEnd: boolean = false - //是否手动结束考试 - private isManual: boolean - //UDP服务序列号 - private serialIndex: number - private fileUtil: FileUtils - private judgeTask: JudgeTask private tempData: Plc //实时计算gps经纬度距离 handDistance = async () => { @@ -290,7 +298,7 @@ export default class Judge { h: (this.tempData.gps.hxj) || 1, }) const distanceClass = AppStorage.get('distanceClass') - distanceClass?.setTimeData( Number(((distance / 100).toFixed(2))) ) + distanceClass?.setTimeData(Number(((distance / 100).toFixed(2)))) } this.prevJd = tJD; this.prevWd = tWD; @@ -325,9 +333,9 @@ export default class Judge { this.isExamEnd = true this.isManual = true } else { - const param302:number = Reflect.get(judgeConfigObj,'302') - const param342:number = Reflect.get(judgeConfigObj,'342') - const param512:number[] =( Reflect.get(judgeConfigObj,'512') || '').split(','); + const param302: number = Reflect.get(judgeConfigObj, '302') + const param342: number = Reflect.get(judgeConfigObj, '342') + const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(','); //单机模式 if (singlePlay) { @@ -336,7 +344,7 @@ export default class Judge { //成绩合格 if (totalScore >= passingGrade && !isEndTip) { if (examSubject == '3' && (param342 == 0 || param342 == 2) && - (param302 != 6 && param302 != 7 && param302 != 8 )) { + (param302 != 6 && param302 != 7 && param302 != 8)) { if (param512[7] != 0) { clearTimeout(this.deductedPopShowTimer) avPlayer.playAudio(['voice/综合评判.mp3']) @@ -437,7 +445,7 @@ export default class Judge { return tempData } // 处理udp plc信号 - handleUdp = async (msg:string) => { + handleUdp = async (msg: string) => { console.info('plc信号', msg) const stachArr = msg.split(',') if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { @@ -451,7 +459,7 @@ export default class Judge { // const str = await senorToWXDataStr(msg); // this.usbService.sendUSB(str) // } - const param350:number = Reflect.get(this.judgeUI.judgeConfigObj,'350') + const param350: number = Reflect.get(this.judgeUI.judgeConfigObj, '350') this.judgeUI.sd = ((param350 == 0 ? plcData.gps.sd : plcData.sensor.cs) as number * 1.852).toFixed(0) + '' this.judgeUI.dw = (Math.floor(plcData.sensor.dw as number) || 0) + '' //TODO 暂时关闭差分检测异常 @@ -469,7 +477,7 @@ export default class Judge { AppStorage.setOrCreate('udpIndex', udpIndex++) } // 处理轨迹plc信号 - handleTrajectoryUdp = async (strArr:string[]) => { + handleTrajectoryUdp = async (strArr: string[]) => { // const { fileLog, setJudgeItem, setJudgeMark, endExam } = this; let num = 2; const judgeTimer = setInterval(async () => { @@ -480,7 +488,7 @@ export default class Judge { this.checkExamIsEnd(true) return } - const msg :Plc= JSON.parse(strArr[num]); + const msg: Plc = JSON.parse(strArr[num]); num++ // 4.过程数据 this.tempData = msg @@ -504,23 +512,35 @@ export default class Judge { // TODO 定时器缺失 // globalThis.judgeTimer = judgeTimer; } - //当前科目二的考试项目 - // private currentKm2ItemsObj: any //本地轨迹回放地址 private trajectoryPath: string + //当前科目二的考试项目 + // private currentKm2ItemsObj: any private isTrajectoryOpen: boolean; // 调代理接口是否断网了 private isJudgeDisConnect: boolean; + // 断网数据补传 + uploadDisConnectData = async () => { + if (!this.isJudgeDisConnect) { + return + } + const folderPath = this.fileLog.folderPath + const examDataStr = await this.fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`); + const examDataArr = examDataStr.split('\n'); + for (let examDataStr of examDataArr) { + const code = await writeObjectOut(JSON.parse(examDataStr)); + } + } // 项目开始接口同步 - beginProject = async (ksxm:number) => { + beginProject = async (ksxm: number) => { const carInfo = AppStorage.get('carInfo'); - const judgeUI = this.judgeUI + const judgeUI = this.judgeUI const time = await GetCurrentTime(); - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) const sbxh = this.getSbbm(ksxm, this.xmxh) - const drvexam:DrvexamType = { - lsh:judgeUI.lsh, + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, kskm: carInfo.examSubject, sfzmhm: judgeUI.idCard, ksxm: project.projectCodeCenter, @@ -531,14 +551,14 @@ export default class Judge { kslx: encodeURI(judgeUI.kslx) || '', kssj: time } - const data:RegulatoryInterfaceParams = { + const data: RegulatoryInterfaceParams = { //系统类别 接口序列号 接口标识 xtlb: '17', jkxlh: judgeUI.serialNumber, jkid: '17C52', drvexam } - const temp:WR = await this.sendWriteObjectOut(data, this.filePath) + const temp: WR = await this.sendWriteObjectOut(data, this.filePath) console.info(judgeTag, '项目开始 end') if (temp.code === 2300007) { this.isJudgeDisConnect = true; @@ -546,15 +566,15 @@ export default class Judge { promptWxCode('17C52', temp.code) } // 项目结束接口同步 - endProject = async (ksxm:number) => { + endProject = async (ksxm: number) => { const carInfo = AppStorage.get('carInfo'); const judgeUI = this.judgeUI; const time = await GetCurrentTime(); - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,ksxm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) const sbxh = judgeUI.examSubject == '3' ? undefined : this.getSbbm(ksxm, this.xmxh) - const drvexam:DrvexamType = { - lsh:judgeUI.lsh, + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, kskm: carInfo.examSubject, sfzmhm: judgeUI.idCard, ksxm: project.projectCodeCenter, @@ -567,13 +587,13 @@ export default class Judge { kslx: encodeURI(judgeUI.kslx) || '', jssj: time } - const data:RegulatoryInterfaceParams = { + const data: RegulatoryInterfaceParams = { xtlb: '17', jkxlh: judgeUI.serialNumber, jkid: '17C55', drvexam } - const temp:WR = await this.sendWriteObjectOut(data, this.filePath) + const temp: WR = await this.sendWriteObjectOut(data, this.filePath) if (temp.code === 2300007) { this.isJudgeDisConnect = true; } @@ -586,9 +606,8 @@ export default class Judge { } private videoData: RecordHandleType private disConnectNum: number = 0; - //调用监管接口 - sendWriteObjectOut:SendWriteObjectOut = async (data, filePath) => { + sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { const temp = await writeObjectOut(data, filePath); console.log("wzj", JSON.stringify(temp)) //断网&网络超时次数计算 @@ -609,17 +628,17 @@ export default class Judge { return temp } // 考试过程照片 - uploadProgressPhoto = async (ksxm:number) => { + uploadProgressPhoto = async (ksxm: number) => { const time = await GetCurrentTime(); const judgeUI = this.judgeUI const plcData = this.plcData const photoBase64 = await this.getPhoto(); const carInfo = AppStorage.get('carInfo'); - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) - const judgeConfig_305:number = Reflect.get(judgeUI.judgeConfigObj, '305') - const drvexam:DrvexamType = { - lsh:judgeUI.lsh, + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, ksxm) + const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305') + const drvexam: DrvexamType = { + lsh: judgeUI.lsh, kskm: carInfo.examSubject, ksxm: project.projectCodeCenter, sfzmhm: judgeUI.idCard, @@ -629,13 +648,13 @@ export default class Judge { cs: Math.floor((judgeConfig_305 == 0 ? plcData.gps.sd : plcData.sensor.cs) * 1.852), ksdd: encodeURI(judgeUI.ksdd) } - const data:RegulatoryInterfaceParams = { + const data: RegulatoryInterfaceParams = { xtlb: '17', jkxlh: judgeUI.serialNumber, jkid: '17C54', drvexam }; - const temp:WR = await this.sendWriteObjectOut(data, this.filePath); + const temp: WR = await this.sendWriteObjectOut(data, this.filePath); if (temp.code === 2300007) { this.isJudgeDisConnect = true } @@ -668,12 +687,12 @@ export default class Judge { this.isExam = !this.judgeUI.singlePlay; (judgeUI.examSubject == '2' ? testKm2Items : testKm3Items).forEach(item => { - const projectCenterObj:ProjectInfo = Reflect.get(judgeUI.projectsCenterObj,item.code) + const projectCenterObj: ProjectInfo = Reflect.get(judgeUI.projectsCenterObj, item.code) - const currentItem:KmItem = Reflect.get(this.kmItems,item.code) - currentItem.code = item.code - currentItem.status = projectCenterObj === undefined ? 0 : (projectCenterObj.isEnd ? 3 : 1) - Reflect.set(this.kmItems,item.code,currentItem) + const currentItem: KmItem = Reflect.get(this.kmItems, item.code) + currentItem.code = item.code + currentItem.status = projectCenterObj === undefined ? 0 : (projectCenterObj.isEnd ? 3 : 1) + Reflect.set(this.kmItems, item.code, currentItem) }) console.info(judgeTag + 'testKmItems', JSON.stringify(this.kmItems)) @@ -695,25 +714,27 @@ export default class Judge { const carName = judgeUI.carName const systemparmArr = judgeUI.systemparmArr const carinfoArr = judgeUI.carinfoArr - const examType = carInfo. examSubject == '2' ? 'km2' : 'km3' + const examType = carInfo.examSubject == '2' ? 'km2' : 'km3' - let allitems:ItemInfo[] = []; + let allitems: ItemInfo[] = []; if (judgeUI.examSubject == '2') { allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { - const cdsb:CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); + const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); const model = this.getModelData(`${examType}/${cdsb.modelKey}.txt`) - const temp:ItemInfo = {xmdm:cdsb.xmdm,xmxh:cdsb.xmxh,model} + const temp: ItemInfo = { + xmdm: cdsb.xmdm, xmxh: cdsb.xmxh, model + } return temp }) } //获取版本号 - const mark:MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => { - const current:MarkRule = Reflect.get(markRuleListObj,ruleKey) + const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => { + const current: MarkRule = Reflect.get(markRuleListObj, ruleKey) return current }) - const initInfo:JudgeInitObj = { - sdkver:await examJudgeVersion(), + const initInfo: JudgeInitObj = { + sdkver: await examJudgeVersion(), appver: AppStorage.get('baseInfo').version, kskm: Number(carInfo.examSubject), kchp: carInfo.plateNo, @@ -731,7 +752,7 @@ export default class Judge { carlist: judgeUI.carlist, carinfo: carinfoArr, }; - let km3Config:Km3JudgeInitConfig = {} + let km3Config: Km3JudgeInitConfig = {} if (judgeUI.examSubject == '3') { km3Config = await this.getKm3JudgeInitConfig(); @@ -754,7 +775,7 @@ export default class Judge { let currentParams: RouteParamsType = router.getParams() as RouteParamsType; const sczb = currentParams.sczb; - const kfdm = currentParams.kfdm; + const kfdm = currentParams.kfdm; const isExam = this.isExam; const judgeUI = this.judgeUI @@ -768,21 +789,25 @@ export default class Judge { const ddxkKfArr = judgeUI.ddxkKfArr const passingScore = judgeUI.passingScore - const ksxm:JudgeKsxm[] = projects.map(project => { - const temp:JudgeKsxm = {xmdm: Number(project.projectCode), xmxh: ''} + const ksxm: JudgeKsxm[] = projects.map(project => { + const temp: JudgeKsxm = { + xmdm: Number(project.projectCode), xmxh: '' + } return temp }) - const ykxm:number[] = (ddxkKsxmArr?.map(projectCenterCode => { - const currentProject:ProjectInfo =Reflect.get(projectsCenterObj, projectCenterCode) + const ykxm: number[] = (ddxkKsxmArr?.map(projectCenterCode => { + const currentProject: ProjectInfo = Reflect.get(projectsCenterObj, projectCenterCode) return Number(currentProject.projectCode) })) || []; - const kfxm:JudgeKfxm[] = isDdxk ? (ddxkKfArr?.map(kf => { - return { xmdm:Number(kf.split(',')[0]), kfdm:kf.split(',')[1]} as JudgeKfxm + const kfxm: JudgeKfxm[] = isDdxk ? (ddxkKfArr?.map(kf => { + return { + xmdm: Number(kf.split(',')[0]), kfdm: kf.split(',')[1] + } as JudgeKfxm })) : [] - const beginInfo:JudgeBeginObj = { + const beginInfo: JudgeBeginObj = { kgid: '012', kgxm: decodeURI(examinerName || ''), exam: isExam ? 1 : 0, @@ -801,7 +826,7 @@ export default class Judge { ykkkcs: 1, wayno: Number(judgeUI.wayno), czlx: 0, - kskssj:await systemTime.getCurrentTime(), + kskssj: await systemTime.getCurrentTime(), passing: Number(passingScore), ksxm, //断点续考 @@ -822,7 +847,7 @@ export default class Judge { return beginInfo } //处理评判过程回调 - handleRealExam = async (strData:string, callBack:Function) => { + handleRealExam = async (strData: string, callBack: Function) => { let examData: JudgeCallBackData = JSON.parse(strData); const getDqxmStr = this.getDqxmStr; @@ -857,7 +882,7 @@ export default class Judge { switch (event) { //项目开始 case 1: - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) project.type = '2'; if (isManualProjectIn) { //手动项目是否在进行中 @@ -870,7 +895,7 @@ export default class Judge { const xmmcStr = project.name; const xmmcCode = project.projectCodeCenter; const xmmcSingleCode = project.projectCode; - const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) kmItem.status = 2; this.xmmcStr = xmmcStr; this.xmmcCode = xmmcCode; @@ -879,41 +904,41 @@ export default class Judge { this.xmdm = xmdm; this.xmxh = xmxh; this.judgeUI.isProjectIn = true - Reflect.set(this.judgeUI.projectsObj,xmdm,project) - Reflect.set(this.kmItems,xmmcCode,kmItem) + Reflect.set(this.judgeUI.projectsObj, xmdm, project) + Reflect.set(this.kmItems, xmmcCode, kmItem) break; //项目结束 case 2: { - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) const xmmcCode = project.projectCodeCenter; project.type = (xmjs.xmhg === 0 ? '4' : '3') //计算项目是否全部结束 - this.judgeUI.isProjectIn = (Reflect.ownKeys(judgeUI.projectsObj).filter((projectKey)=>{ - const fillProject:ProjectInfo = Reflect.get( judgeUI.projectsObj,projectKey) + this.judgeUI.isProjectIn = (Reflect.ownKeys(judgeUI.projectsObj).filter((projectKey) => { + const fillProject: ProjectInfo = Reflect.get(judgeUI.projectsObj, projectKey) return fillProject.type == '2' }).length) > 0; if (isManualProjectIn) { this.judgeUI.isManualProjectIn = false } - const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) kmItem.status = 3; //统计必考项目数量 this.xmmcStr = '无'; this.xmmcCode = ''; this.xmdm = ''; this.judgeUI.currentXmdm = undefined; - Reflect.set(this.judgeUI.projectsObj,xmdm,project) - Reflect.set(this.kmItems,xmmcCode,kmItem) + Reflect.set(this.judgeUI.projectsObj, xmdm, project) + Reflect.set(this.kmItems, xmmcCode, kmItem) break; } //扣分 case 3: const thisKf = this.getKfStr(`${kf.xmdm}_${kf.kfdm}`) - const kfObj:JudgeEventKf = { + const kfObj: JudgeEventKf = { //扣分项目名称 xmmcStr: this.getDqxmStr(kf.xmdm), xmdm: kf.xmdm, @@ -932,10 +957,10 @@ export default class Judge { this.kfArr.push(kfObj) this.judgeUI.totalScore += thisKf.score * 1; if (kf.xmdm != 20) { - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,kf.xmdm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, kf.xmdm) const type = project.type; - project.type = (type == '3' || type == '4') ? '4' : '5' - Reflect.set(this.judgeUI.projectsObj,kf.xmdm,project) + project.type = (type == '3' || type == '4') ? '4' : '5' + Reflect.set(this.judgeUI.projectsObj, kf.xmdm, project) } break; @@ -947,23 +972,25 @@ export default class Judge { //考试结束 case 5: this.ksjs = ksjs; - await fileLog.setExamJudgeData(JSON.stringify({method: 'examJudgeEndExam'})) + await fileLog.setExamJudgeData(JSON.stringify({ + method: 'examJudgeEndExam' + })) break; //项目取消 case 6: { console.info(judgeTag, '项目取消'); const xmdm = xmqx.xmdm; - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) // const examSubject = this.judgeUI.examSubject const xmmcCode = project.projectCodeCenter; // const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); // avPlayer.playAudio([`voice/${voiceCode}.mp3`],true) project.type = '1' - const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) - Reflect.set(this.judgeUI.projectsObj,xmdm,project) + const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) + Reflect.set(this.judgeUI.projectsObj, xmdm, project) kmItem.status = 1 - Reflect.set(this.kmItems,xmmcCode,kmItem) + Reflect.set(this.kmItems, xmmcCode, kmItem) break; } @@ -985,24 +1012,24 @@ export default class Judge { //预进项目事件 case 10: { - const param611:JudgeConfigObj = Reflect.get(judgeConfigObj,'611') || '' + const param611: JudgeConfigObj = Reflect.get(judgeConfigObj, '611') || '' const xmdm = precast.xmdm const xmxh = precast.xmxh - const project:ProjectInfo = Reflect.get(judgeUI.projectsObj,xmdm) + const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) const xmmcCode = project.projectCodeCenter const projectCode = project.projectCode // const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; // const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; - const kmItem:KmItem = Reflect.get(this.kmItems,xmmcCode) + const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) kmItem.status = 2; - Reflect.set(this.kmItems,xmmcCode,project) + Reflect.set(this.kmItems, xmmcCode, project) this.xmmcStr = xmmcStr; this.xmmcCode = xmmcCode; this.xmdm = xmdm; this.xmxh = xmxh; this.xmmcSingleCode = xmmcSingleCode; project.type = '2'; - Reflect.set(this.judgeUI.projectsObj,xmdm,project) + Reflect.set(this.judgeUI.projectsObj, xmdm, project) } break; //差分事件 @@ -1014,7 +1041,7 @@ export default class Judge { } await callBack({ //项目名称 考车状态 扣分arr - xmmcStr:this.xmmcStr, carztStr:this.carztStr, kfArrt:this.kfArr + xmmcStr: this.xmmcStr, carztStr: this.carztStr, kfArrt: this.kfArr }); //语音播报 @@ -1026,158 +1053,163 @@ export default class Judge { } } // 更改考试状态 - goVoiceAnnounce = async (event:number, xmdm:number, kf:JudgeEventKf[], xmjs:JudgeXmjs, ksjs:JudgeKsjs, xmxh:string) => { + goVoiceAnnounce = + async (event: number, xmdm: number, kf: JudgeEventKf[], xmjs: JudgeXmjs, ksjs: JudgeKsjs, xmxh: string) => { - const beginProject = this.beginProject - const pointsDedute = this.pointsDedute - const endProject = this.endProject - const avPlayer = this.avPlayer - const uploadProgressPhoto = this.uploadProgressPhoto - const judgeTask = this.judgeTask - const handEndExam = this.handEndExam - const judgeUI = this.judgeUI - const checkExamIsEnd = this.checkExamIsEnd - const checkProjectIsStart = this.checkProjectIsStart - const lane = this.lane - const closeAllFiles = this.closeAllFiles + const beginProject = this.beginProject + const pointsDedute = this.pointsDedute + const endProject = this.endProject + const avPlayer = this.avPlayer + const uploadProgressPhoto = this.uploadProgressPhoto + const judgeTask = this.judgeTask + const handEndExam = this.handEndExam + const judgeUI = this.judgeUI + const checkExamIsEnd = this.checkExamIsEnd + const checkProjectIsStart = this.checkProjectIsStart + const lane = this.lane + const closeAllFiles = this.closeAllFiles - const projectsObj = judgeUI.projectsObj - const judgeConfigObj = judgeUI.judgeConfigObj - const examSubject = judgeUI.examSubject - const jl = judgeUI.jl - const isAllProjectsEnd = judgeUI.isAllProjectsEnd + const projectsObj = judgeUI.projectsObj + const judgeConfigObj = judgeUI.judgeConfigObj + const examSubject = judgeUI.examSubject + const jl = judgeUI.jl + const isAllProjectsEnd = judgeUI.isAllProjectsEnd - const kfLen = kf.length; - //不报语音的项目列表 - // const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') - // const param611 = judgeConfigObj['611'] || ''; - // const [f, s] = param611.split('/') - switch (event) { - // 项目开始 - case 1: - const param512:JudgeConfigObj = (Reflect.get(judgeConfigObj,'512') || '').split(','); - const project:ProjectInfo = Reflect.get(projectsObj,xmdm) - const code = project.projectCodeCenter; - const isEnd = project.isEnd; - // const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) - // if (!ignoreVoiceCodeArr.includes(code)) { - // if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){ - // //倒出入库、桩考\进项目语音控制 - // }else{ - // kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) - // } - // } - setTimeout(() => { - if (Reflect.get(param512,7) != 0) { - clearTimeout(this.deductedPopShowTimer) - this.judgeUI.isDeductedPopShow = true - } - }, 200) - //项目已考不上传监管信息 - if (!isEnd) { - judgeTask.addTask(async () => { - console.info(judgeTag, `项目开始-${xmdm}-${project.name}`) - await beginProject(xmdm) - }, {isDelay: true}) - judgeTask.addTask(async () => { - console.info(judgeTag, `项目-${xmdm}-上传照片 start`) - await uploadProgressPhoto(xmdm) - }, {isDelay: true}) - project.isUpload = true; - Reflect.set(this.judgeUI.projects,xmdm,project) - } - break; - - // 项目结束 - case 2: { - const project:ProjectInfo = Reflect.get(projectsObj,xmdm) - const endCode = project.projectCodeCenter; - const projectIsEnd = project.isEnd; - // const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh) - // if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { - // endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) - // } - const isStart = await this.checkProjectIsStart(xmdm, 1); - if (isStart) { - //项目结束了就不再生成数据 - console.info(judgeTag + ' projectIsEnd =>', projectIsEnd) - if (!projectIsEnd) { + const kfLen = kf.length; + //不报语音的项目列表 + // const ignoreVoiceCodeArr = (judgeConfigObj['312'] || '').split(',') + // const param611 = judgeConfigObj['611'] || ''; + // const [f, s] = param611.split('/') + switch (event) { + // 项目开始 + case 1: + const param512: JudgeConfigObj = (Reflect.get(judgeConfigObj, '512') || '').split(','); + const project: ProjectInfo = Reflect.get(projectsObj, xmdm) + const code = project.projectCodeCenter; + const isEnd = project.isEnd; + // const kmCode = getKmProjectVoice(code, 1, judgeConfigObj, lane, xmxh) + // if (!ignoreVoiceCodeArr.includes(code)) { + // if(examSubject == 2 && ((xmdm == 0 && f == 2) || (xmdm == 1 && s == 2) || xmdm == 3)){ + // //倒出入库、桩考\进项目语音控制 + // }else{ + // kmCode && avPlayer.playAudio([`voice/${kmCode}.mp3`],true) + // } + // } + setTimeout(() => { + if (Reflect.get(param512, 7) != 0) { + clearTimeout(this.deductedPopShowTimer) + this.judgeUI.isDeductedPopShow = true + } + }, 200) + //项目已考不上传监管信息 + if (!isEnd) { judgeTask.addTask(async () => { - console.info(judgeTag, `项目结束-${xmdm}-${project.name}`) - await endProject(xmdm); - this.xmmcSingleCode = '0'; - this.xmmcEndCode = undefined; + console.info(judgeTag, `项目开始-${xmdm}-${project.name}`) + await beginProject(xmdm) + }, { + isDelay: true + }) + judgeTask.addTask(async () => { + console.info(judgeTag, `项目-${xmdm}-上传照片 start`) + await uploadProgressPhoto(xmdm) + }, { + isDelay: true + }) + project.isUpload = true; + Reflect.set(this.judgeUI.projects, xmdm, project) + } + break; + + // 项目结束 + case 2: { + const project: ProjectInfo = Reflect.get(projectsObj, xmdm) + const endCode = project.projectCodeCenter; + const projectIsEnd = project.isEnd; + // const endKmCode = getKmProjectVoice(endCode, 2, judgeConfigObj, lane, xmxh) + // if (!ignoreVoiceCodeArr.includes(endCode) && examSubject == 3) { + // endKmCode && avPlayer.playAudio([`voice/${endKmCode}.mp3`]) + // } + const isStart = await this.checkProjectIsStart(xmdm, 1); + if (isStart) { + //项目结束了就不再生成数据 + console.info(judgeTag + ' projectIsEnd =>', projectIsEnd) + if (!projectIsEnd) { + judgeTask.addTask(async () => { + console.info(judgeTag, `项目结束-${xmdm}-${project.name}`) + await endProject(xmdm); + this.xmmcSingleCode = '0'; + this.xmmcEndCode = undefined; + }, { + isDelay: true + }) + } + } + if (!this.judgeUI.isProjectIn) { + this.deductedPopShowTimer = setTimeout(() => { + this.judgeUI.isDeductedPopShow = false + }, (Reflect.get(param512, 5) || 0) * 1000) + } + project.isEnd = true; + Reflect.set(this.judgeUI.projects, xmdm, project) + break; + } + + // 扣分 + case 3: + console.info('surenjun', '扣分开始') + //扣分时实时播报语音(0-否+1-是) + const currentKf = kf[kfLen -1]; + if (judgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '1') || + (examSubject == '3' && judgeConfigObj['418'] == '1')) { + avPlayer.playAudio([`voice/${currentKf.markcatalog}.mp3`, `voice/mark_${Math.abs(currentKf.score)}.mp3`]) + } + const isStart = await checkProjectIsStart(currentKf.xmdm, 2, currentKf); + if (isStart) { + await judgeTask.addTask(async () => { + console.info(judgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`) + await pointsDedute(currentKf.xmdm, currentKf) }, { isDelay: true }) } - } - if (!this.judgeUI.isProjectIn) { - this.deductedPopShowTimer = setTimeout(() => { - this.judgeUI.isDeductedPopShow = false - }, (Reflect.get(param512,5) || 0) * 1000) - } - project.isEnd = true; - Reflect.set(this.judgeUI.projects,xmdm,project) - break; - } + break; - // 扣分 - case 3: - console.info('surenjun', '扣分开始') - //扣分时实时播报语音(0-否+1-是) - const currentKf = kf[kfLen -1]; - if (judgeConfig.kfVoiceOpen || (examSubject == '2' && judgeConfigObj['618'] == '1') || - (examSubject == '3' && judgeConfigObj['418'] == '1')) { - avPlayer.playAudio([`voice/${currentKf.markcatalog}.mp3`, `voice/mark_${Math.abs(currentKf.score)}.mp3`]) - } - const isStart = await checkProjectIsStart(currentKf.xmdm, 2, currentKf); - if (isStart) { - await judgeTask.addTask(async () => { - console.info(judgeTag, `项目扣分-${currentKf.markcatalog}-${currentKf.desc}`) - await pointsDedute(currentKf.xmdm, currentKf) - }, { - isDelay: true + // 考车状态 + case 4: + break + + // 考试结束 + case 5: + console.info(judgeTag, '考试结束') + //关闭录像 + const singlePlay = AppStorage.get('singlePlay') + if (!singlePlay) { + await endRecordVideo(this.videoData) + } + judgeTask.addTask(async () => { + console.info(judgeTag, '考试结束 start') + AppStorage.setOrCreate('isJudge', false) + await handEndExam(ksjs) }) - } - break; - - // 考车状态 - case 4: - break - - // 考试结束 - case 5: - console.info(judgeTag, '考试结束') - //关闭录像 - const singlePlay = AppStorage.get('singlePlay') - if (!singlePlay) { - await endRecordVideo(this.videoData) - } - judgeTask.addTask(async () => { - console.info(judgeTag, '考试结束 start') - AppStorage.setOrCreate('isJudge', false) - await handEndExam(ksjs) - }) - // TODO待修改 - // clearInterval(globalThis.judgeTimer) - break - default: - break + // TODO待修改 + // clearInterval(globalThis.judgeTimer) + break + default: + break + } + if (event == 2 || event == 3) { + setTimeout(() => { + this.judgeUI.kfArrScroller.scrollTo({ + yOffset: 999999, xOffset: 0 + }) + }, 500) + //统计必考项目完成数量 + await this.setCountItems(); + await checkExamIsEnd() + } } - if (event == 2 || event == 3) { - setTimeout(() => { - this.judgeUI.kfArrScroller.scrollTo({ - yOffset: 999999, xOffset: 0 - }) - }, 500) - //统计必考项目完成数量 - await this.setCountItems(); - await checkExamIsEnd() - } - } // 考试扣分 - pointsDedute = async (ksxm:number, kf:JudgeEventKf) => { + pointsDedute = async (ksxm: number, kf: JudgeEventKf) => { const carInfo = AppStorage.get('carInfo'); const examSubject = carInfo.examSubject const plateNo = carInfo.plateNo @@ -1202,7 +1234,7 @@ export default class Judge { const checkProjects = ['17', '41', '1']; //获取正在进行的项目 const inProjects = Reflect.ownKeys(projectsObj).filter(projectKey => { - const project:ProjectInfo =Reflect.get(projectsObj,projectKey) + const project: ProjectInfo = Reflect.get(projectsObj, projectKey) return project.type == '2' }); @@ -1213,15 +1245,15 @@ export default class Judge { } }) - const ksxmD:string = project == undefined + const ksxmD: string = project == undefined ? (commonKsxm ? (project.projectCodeCenter) : (examSubject == '3' ? '30000' : (xmmcEndCode == undefined ? '10000' : xmmcEndCode))) : project.projectCodeCenter - const drvexam:DrvexamType = { + const drvexam: DrvexamType = { lsh, kskm: examSubject, - ksxm:ksxmD, + ksxm: ksxmD, kfxm: kf.markcatalog, kfxmmx: `${ksxm},${kf.markserial}`, sfzmhm: idCard, @@ -1231,7 +1263,12 @@ export default class Judge { ksdd: encodeURI(ksdd), kfsj: time } - const data:RegulatoryInterfaceParams = {xtlb: '17', jkxlh: serialNumber, jkid: '17C53', drvexam} + const data: RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: serialNumber, + jkid: '17C53', + drvexam + } console.info(judgeTag + 'ksxm=>', data.drvexam.ksxm) const temp = await this.sendWriteObjectOut(data, filePath); @@ -1239,7 +1276,7 @@ export default class Judge { this.isJudgeDisConnect = true } console.info(judgeTag, '项目扣分 end') - promptWxCode('17C53',temp.code) + promptWxCode('17C53', temp.code) } // 评判语音提示 goJudgeVoice = async (sound: JudgeSound) => { @@ -1249,14 +1286,14 @@ export default class Judge { //判断是不是模拟灯光语音 if (sound.type == 1) { avPlayer.playAudio([`voice/${sound.code[0]}.mp3`], false, () => { - examJudgeSoundEnd( { + examJudgeSoundEnd({ xmdm: sound.xmdm, code: sound.code[0], type: sound.type }) fileLog.setExamJudgeData(JSON.stringify({ method: 'examJudgeSoundEnd', itemno: sound.xmdm, code: sound.code[0], - type:sound.type, + type: sound.type, })) }) } else { @@ -1287,7 +1324,7 @@ export default class Judge { //计算考试分数 // this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0; const singlePlay = AppStorage.get('singlePlay') - const param302:string = Reflect.get(judgeConfigObj, '302') + const param302: string = Reflect.get(judgeConfigObj, '302') // globalThis.windowClass.setWindowSystemBarEnable(['navigation']) //自动退出待验证并且不合格 @@ -1307,7 +1344,8 @@ export default class Judge { if (examSubject == '3') { if (totalScore < passingScore) { //考试不合格;考试模式,自动退出; - if (param302 == '4' || param302 =='5' || param302 == '7' || param302 == '8') {} + if (param302 == '4' || param302 == '5' || param302 == '7' || param302 == '8') { + } } else { //考试合格 } @@ -1359,7 +1397,7 @@ export default class Judge { const d4 = ksjs.d4; const d5 = ksjs.d5; - const drvexam:DrvexamType = { + const drvexam: DrvexamType = { lsh, kchp: encodeURI(plateNo), kskm: examSubject, @@ -1372,12 +1410,17 @@ export default class Judge { dwlc: [d1, d2, d3, d4, d5].map((d, index) => `${index + 1},${Math.floor(d / 100)}`).join(';'), } - const data:RegulatoryInterfaceParams = {xtlb: '17',jkxlh: serialNumber,jkid: '17C56', drvexam} + const data: RegulatoryInterfaceParams = { + xtlb: '17', + jkxlh: serialNumber, + jkid: '17C56', + drvexam + } let backTimeOut = setTimeout(() => { router.back() }, 90 * 1000) const temp = await this.sendWriteObjectOut(data, filePath); - promptWxCode('17C56',temp.code) + promptWxCode('17C56', temp.code) if (temp.code != 1) { avPlayer.playAudio(['voice/监管失败.mp3']) @@ -1392,7 +1435,7 @@ export default class Judge { return } console.info(judgeTag, '考试结束 end') - const param302:string = Reflect.get(judgeConfigObj,'302') + const param302: string = Reflect.get(judgeConfigObj, '302') judgeUI.loadingPopupVisible = true; let currentKssycs = '0'; let voiceURL = '' @@ -1459,7 +1502,7 @@ export default class Judge { //语音播放扣分项 let score = 0; //结束考试时候是否播报一遍所有扣分 - const param634:string = Reflect.get(judgeConfigObj,'634') + const param634: string = Reflect.get(judgeConfigObj, '634') if (kfArr.length && ((examSubject == '2' && param634 == '1') || examSubject == '3')) { avPlayer.playAudio([`voice/kfdesc.mp3`], false, () => { try { @@ -1501,14 +1544,14 @@ export default class Judge { } // 当前项目转换 - getDqxmStr:GetDqxmStr = (xmdm) => { - const project:ProjectInfo = Reflect.get(this.judgeUI.projectsObj,xmdm) + getDqxmStr: GetDqxmStr = (xmdm) => { + const project: ProjectInfo = Reflect.get(this.judgeUI.projectsObj, xmdm) return project?.abbreviation || '通用评判' } // 扣分项目转换 - getKfStr:GetKfStr = (code) => { + getKfStr: GetKfStr = (code) => { const markRuleListObj = this.judgeUI.markRuleListObj; - const thisMark:MarkRule = Reflect.get(markRuleListObj,code) + const thisMark: MarkRule = Reflect.get(markRuleListObj, code) return { desc: thisMark.markshow, score: thisMark.markreal, @@ -1635,11 +1678,11 @@ export default class Judge { // return Array2Byte(tempArr) // } //获取场地序号 - getSbxh:GetgSbbm = (ksxm, xmxh) => { + getSbxh: GetgSbbm = (ksxm, xmxh) => { const judgeUI = this.judgeUI; const projectsObj = judgeUI.projectsObj; const cdsbInfoObj = judgeUI.cdsbInfoObj; - const project:ProjectInfo = Reflect.get(projectsObj, ksxm); + const project: ProjectInfo = Reflect.get(projectsObj, ksxm); if (judgeUI.examSubject == '3') { return '0000000000' } @@ -1647,16 +1690,15 @@ export default class Judge { return '0000000000' } const projectKey = `${ksxm}_${xmxh}`; - const currentCdsb:CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} - const sbxh:string = currentCdsb.sbbh || '0000000000' + const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + const sbxh: string = currentCdsb.sbbh || '0000000000' return sbxh } - - getSbbm:GetgSbbm = (ksxm, xmxh) => { + getSbbm: GetgSbbm = (ksxm, xmxh) => { const judgeUI = this.judgeUI; const cdsbInfoObj = judgeUI.cdsbInfoObj; const projectsObj = judgeUI.projectsObj; - const project:ProjectInfo = Reflect.get(projectsObj, ksxm); + const project: ProjectInfo = Reflect.get(projectsObj, ksxm); //科目三不需要 if (judgeUI.examSubject == '3') { return undefined @@ -1665,21 +1707,23 @@ export default class Judge { return '00000000' } const projectKey = `${ksxm}_${xmxh}`; - const currentCdsb:CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} - const sbxh:string = currentCdsb.sbbm || '00000000' + const currentCdsb: CDSBInfo = Reflect.get(cdsbInfoObj, projectKey) || {} + const sbxh: string = currentCdsb.sbbm || '00000000' return sbxh } // 中心所有项目转换 getTranslateProject = () => { const examSubject = this.judgeUI.examSubject; - const tempItems:TKmItem[] = (examSubject == '2' ? testKm2Items : testKm3Items).map(item => { - const kmItem:KmItem = Reflect.get(this.kmItems,item.code) + const tempItems: TKmItem[] = (examSubject == '2' ? testKm2Items : testKm3Items).map(item => { + const kmItem: KmItem = Reflect.get(this.kmItems, item.code) const status = getCenterProjectStatus(kmItem.status) - const temp:TKmItem = {code: item.code, status} + const temp: TKmItem = { + code: item.code, status + } return temp }) - const arr:string[] = []; + 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) @@ -1699,12 +1743,12 @@ export default class Judge { return arr } // 获取考试项目详情 - getProjectInfo = (projectCode:number) => { - const project:ProjectInfo = Reflect.get(this.judgeUI.projectsObj, projectCode) + getProjectInfo = (projectCode: number) => { + const project: ProjectInfo = Reflect.get(this.judgeUI.projectsObj, projectCode) return project } // 获取模型数据 - getModelData = (modelName:string) => { + getModelData = (modelName: string) => { const modelData = this.fileModel.getModelContent(this.modelPath, modelName); return modelData } @@ -1716,7 +1760,7 @@ export default class Judge { // 所有考试项目数量 项目已考项目数量 let allProjectNum = 0, allEndProjectsNum = 0; Reflect.ownKeys(projectsObj).forEach(projectKey => { - const projectObj:ProjectInfo = Reflect.get(projectsObj, projectKey) + const projectObj: ProjectInfo = Reflect.get(projectsObj, projectKey) const type = projectObj.type const isRequired = projectObj.isRequired allProjectNum += 1; @@ -1741,7 +1785,7 @@ export default class Judge { this.judgeUI.isAllProjectsEnd = (allProjectNum - allEndProjectsNum === 0) } // 检测差分状态 - checkDwzt = async (type:number) => { + checkDwzt = async (type: number) => { const avPlayer = this.avPlayer; switch (type) { case 0: @@ -1779,7 +1823,7 @@ export default class Judge { //开始评判 private async judging(callBack: Function) { - const judgeUI = this.judgeUI; + const judgeUI = this.judgeUI; const name = judgeUI.name const lsh = judgeUI.lsh @@ -1803,22 +1847,22 @@ export default class Judge { const avPlayer = this.avPlayer; const isJudgeInitBool = AppStorage.get('isJudgeInitBool'); - let strArr:string[] = []; + let strArr: string[] = []; if (isTrajectoryOpen) { const folderPath = await this.fileUtil.initFolder(trajectoryPath); - const str:string = await this.fileUtil.readFile(folderPath) + const str: string = await this.fileUtil.readFile(folderPath) strArr = str.split('\n') } //日志回调 console.info(judgeTag, '1.进入评判入口') - await examJudgeSetLogCallback(3, async (level:number, info:string, len:number) => { + await examJudgeSetLogCallback(3, async (level: number, info: string, len: number) => { console.log('评判日志:' + info) await fileLog.setExamJudgeLogData(info); }) console.info(judgeTag, '2.注册日志回调完成') - let initInfo:JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); + let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.getJudgeInitData(); await fileLog.setExamJudgeData(JSON.stringify(initInfo)) //相关评判初始化只做一次 if (!isJudgeInitBool) { @@ -1828,15 +1872,15 @@ export default class Judge { } AppStorage.setOrCreate('isJudge', true) // 2.评判过程回调 - await examJudgeSetRealExamCallback(async (strData:string, len:number) => { + await examJudgeSetRealExamCallback(async (strData: string, len: number) => { await fileLog.setExamJudgeCallbackData(strData) console.info('评判回调数据', strData) this.handleRealExam(strData, callBack) }) - await examJudgeSetPerformCallback(async (info:string) => { + await examJudgeSetPerformCallback(async (info: string) => { console.info('评判实时数据', info) - const performInfo:JudgePerformInfo = JSON.parse(info) + const performInfo: JudgePerformInfo = JSON.parse(info) this.performInfo = performInfo const jl = Math.floor((performInfo.qjjl + performInfo.dcjl) / 100); if (jl > Number(this.judgeUI.examMileage)) { @@ -1847,12 +1891,12 @@ export default class Judge { // globalThis.laneData = performInfo.lane; }) - let beginExamInfo:JudgeBeginObj = undefined + let beginExamInfo: JudgeBeginObj = undefined // 3.开始考试 - if(isTrajectoryOpen){ - beginExamInfo = JSON.parse(strArr[1]) + if (isTrajectoryOpen) { + beginExamInfo = JSON.parse(strArr[1]) beginExamInfo.replay = 1 - }else{ + } else { beginExamInfo = await getJudgeBeginData() } await fileLog.setExamJudgeData(JSON.stringify(beginExamInfo)) diff --git a/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets b/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets index 702abd1e..dfadf8a5 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets +++ b/entry/src/main/ets/pages/judgeSDK/utils/voiceAnnouncements.ets @@ -1,13 +1,12 @@ import media from '@ohos.multimedia.media'; import Prompt from '@system.prompt'; -import url from '@ohos.url'; -import fileuri from "@ohos.file.fileuri"; import mediaLibrary from '@ohos.multimedia.mediaLibrary'; import common from '@ohos.app.ability.common'; +import { BusinessError } from '@ohos.base'; const TAG = 'VoiceAnnounce' -interface Queue{ +interface Queue { url: string, callback?: Function } @@ -32,13 +31,14 @@ export default class VoiceAnnounce { const queue = this.queue; const tempUrls: Queue[] = urls.map((url, index) => { - const callback:Function|undefined = (index === urls.length - 1) ? callbackFn : undefined - const temp:Queue = {url, callback} + const callback: Function | undefined = (index === urls.length - 1) ? callbackFn : undefined + const temp: Queue = { + url, callback + } return temp }); - if (shit) { //队列清空,重新初始化 this.isStopped = true; @@ -92,7 +92,7 @@ class AVPlayer { } // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例 - async play(name:string, callback:Function):Promise { + async play(name: string, callback: Function): Promise { try { //检查SD中的语音 // console.info('surenjun name',name) @@ -144,7 +144,7 @@ class AVPlayer { } } - async queryFile(displayName:string): Promise { + async queryFile(displayName: string): Promise { return new Promise(async (resolve, reject) => { const context = AppStorage.get('context') const mediaLib = mediaLibrary.getMediaLibrary(context); @@ -174,8 +174,9 @@ class AVPlayer { } // 注册avplayer回调函数 - setAVPlayerCallback(callBack:Function) { - this.avPlayer.on('error', (err) => { + setAVPlayerCallback(callBack: Function) { + this.avPlayer.on('error', (err: BusinessError) => { + console.log(TAG, '播放器错误', JSON.stringify(err)) this.avPlayer && this.avPlayer.stop() this.avPlayer && this.avPlayer.reset() this.avPlayer && this.avPlayer.release()