From 973d5fa32c19ad070b1d94acb49ca92285941fdf Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Wed, 19 Mar 2025 14:53:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=87=BD=E6=95=B0=E8=B0=83=EF=BF=BD=EF=BF=BD?= =?UTF-8?q?=EF=BF=BD=E5=92=8C=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/model/Common.ets | 3 + entry/src/main/ets/model/Table.ets | 122 +++++++++++ entry/src/main/ets/pages/Index.ets | 7 +- entry/src/main/ets/pages/Judge.ets | 205 +++++++++--------- .../ets/pages/compontents/FaceCompare.ets | 52 +++-- .../pages/judgeSDK/{judge.ts => judge.ets} | 201 ++++++++--------- 6 files changed, 343 insertions(+), 247 deletions(-) rename entry/src/main/ets/pages/judgeSDK/{judge.ts => judge.ets} (96%) diff --git a/entry/src/main/ets/model/Common.ets b/entry/src/main/ets/model/Common.ets index 13d47a20..4356a5a9 100644 --- a/entry/src/main/ets/model/Common.ets +++ b/entry/src/main/ets/model/Common.ets @@ -95,6 +95,9 @@ export interface RouteParamsType { sczb?: string; kfdm?: string; type?: string; + wayno?: string; + kString?: string; + examItems?: string; } // 车辆信息 diff --git a/entry/src/main/ets/model/Table.ets b/entry/src/main/ets/model/Table.ets index 8dba9259..1b44272b 100644 --- a/entry/src/main/ets/model/Table.ets +++ b/entry/src/main/ets/model/Table.ets @@ -90,4 +90,126 @@ export interface MASYSSETTableType { v_no?: string v_name?: string v_value?: string +} + +// 'id', 'car_mac', 'status', 'voiceip', 'carno', 'carcode', 'cartype', 'device_status', 'carip', 'pulse1', +// 'pulse2', 'isface', 'bk1', 'ismapcollect', 'bk2', 'exampointcode', 'software_version', 'typename', 'vin', +// 'voicetype', 'em', 'carclass', 'carid', 'flag', 'kscx', 'x_mch' +export interface ES_CARINFOType { + id?: string + car_mac?: string + status?: string + voiceip?: string + carno?: string + carcode?: string + cartype?: string + device_status?: string + carip?: string + pulse1?: string + pulse2?: string + isface?: string + bk1?: string + ismapcollect?: string + bk2?: string + exampointcode?: string + software_version?: string + typename?: string + vin?: string + voicetype?: string + em?: string + carclass?: string + carid?: string + flag?: string + kscx?: string + x_mch?: string +} + +// 'id', 'no1', 'no2', 'no3', 'txt1', 'txt2', 'txt3' +export interface MA_SYSTEMPARMType { + id?: string + no1?: string + no2?: string + no3?: string + txt1?: string + txt2?: string + txt3?: string + NO1?: number, + NO2?: number, + NO3?: number, + TXT1?: string, + TXT2?: string, + TXT3?: string, +} + +// 'id', 'sbbm', 'itemsno', 'sbbh', 'kdid', 'bk3' +export interface MA_CDSBINFOType { + id?: string + sbbm?: string + itemsno?: string + sbbh?: string + kdid?: string + bk3?: string +} + +// 'id', 'cininfo', 'setup9', 'nextinfo', 'setup7', 'setup8', 'setup5', 'carlist', 'setup6', 'setup3', +// 'setup4', 'setup1', 'setup2', 'itemsno', 'end_cardsno', 'freqinfo' +export interface MA_ITEMINFOType { + id?: string + cininfo?: string + setup9?: string + nextinfo?: string + setup7?: string + setup8?: string + setup5?: string + carlist?: string + setup6?: string + setup3?: string + setup4?: string + setup1?: string + setup2?: string + itemsno?: string + end_cardsno?: string + freqinfo?: string +} + +// 'id', 'point_no', 'point_no_f', 'gps_e', 'gps_e_location', 'gps_n', 'gps_n_location', 'f_gps_e', +// 'f_gps_n', 'point_type', 'road_code', 'visible', 'passed' +export interface MA_MAP_POINTType { + id?: string + point_no?: string + point_no_f?: string + gps_e?: string + gps_e_location?: string + gps_n?: string + gps_n_location?: string + f_gps_e?: string + f_gps_n?: string + point_type?: string + road_code?: string + visible?: string + passed?: string +} + +// id', 'point_no', 'itemno', 'itemno1', 'subname' +export interface MA_MAP_POINT_ITEMType { + id?: string + point_no?: string + itemno?: string + itemno1?: string + subname?: string +} + +// 'id', 'itemno', 'markserial', 'markdepend', 'markcatalog', 'markstandard', 'markreal', 'markshow', 'txt1', +// 'kfxh' +export interface MA_MARKRULEType { + id?: string + itemno?: string + markserial?: string + markdepend?: string + markcatalog?: string + markstandard?: string + markreal?: string + markshow?: string + txt1?: string + kfxh?: string } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 8171ac76..f46c97ad 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -4,13 +4,11 @@ import router from '@ohos.router'; import { getCurrentTime, setCurrentTime, string2Bytes } from '../common/utils/tools'; import { FileHelper } from '../common/service/FileHelper'; import { getEsCarModel, getSyncData, } from '../common/service/initable'; -import FileUtil from '../common/utils/File'; import { getUDP, getUDP2 } from '../common/utils/GlobalUdp'; import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; -import { getSingleCenterTable, setliushuiNum, takePhotoFn } from '../common/service/indexService'; -import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; +import { setliushuiNum, takePhotoFn } from '../common/service/indexService'; import promptAction from '@ohos.promptAction'; import errorMsgDialog from './compontents/errorMsgDialog'; import GetDistance from '../common/utils/GetDistance'; @@ -18,7 +16,7 @@ import { delPic } from '../service/videoService'; import imageBtn from './compontents/imageBtn'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import { BaseInfoType } from '../model/Common'; -import { CarInfoType } from '../model/CarCheck'; +import { CarInfoType } from '../model'; import { InitializeTheCentralTableType, MASYSSETTableType, TimeInfo } from '../model'; import { GetCarInfo, GetDeviceInfo, UseAuth } from './Index/utils'; import { GetSyncData, InitializeTheCentralTable } from '../utils/table/Operation'; @@ -399,7 +397,6 @@ struct Index { singlePlay: this.singlePlay } this.loading = true - console.log("sql 1111") // getSingleCenterTable(param).then((ret) => { InitializeTheCentralTable(param).then((ret) => { diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 25fd1728..ad97a59d 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -30,7 +30,21 @@ import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import FileUtil from '../common/utils/File'; import SignDisplayCom from './compontents/signDisplayCom'; -import { CarInfoType, CommonType, KfdmType, User } from '../model'; +import { + CarInfoType, + CommonType, + ES_CARINFOType, + KfdmType, + MASYSSETTableType, + MA_CDSBINFOType, + MA_ITEMINFOType, + MA_MAP_POINTType, + MA_MAP_POINT_ITEMType, + MA_MARKRULEType, + MA_SYSTEMPARMType, + RouteParamsType, + User +} from '../model'; import { GetSyncData } from '../utils/table/Operation'; @Entry @@ -197,7 +211,8 @@ struct Index { // 查询考车信息 async initCar() { - const result = await getSyncData('ES_CARINFO') + // const result = await getSyncData('ES_CARINFO') + const result = await GetSyncData("ES_CARINFO") const carInfo = result[0] || {}; this.carName = decodeURI(carInfo.carclass) this.carType = carInfo.kscx @@ -206,6 +221,7 @@ struct Index { IPADDR: '', CARCLASS: decodeURI(carInfo.carclass), KSCX: carInfo.kscx, + // TODO 确定一下是否有这个字段,表定义中没有 CARNAME: decodeURI(carInfo.carname), FLAG: carInfo.flag, BK1: carInfo.bk1, @@ -217,23 +233,23 @@ 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 = xm || '测试考生'; - this.idCard = sfzmhm || '01234567891010'; + 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' : lsh; - this.kszp = kszp; - this.ksdd = ksdd; - this.kssycs = kssycs; - this.ksxl = ksxl; - this.wayno = ksxl; - this.xldm = xldm; - this.kslx = kslx; + this.kszp = stuInfo.kszp; + this.ksdd = stuInfo.ksdd; + this.kssycs = stuInfo.kssycs; + this.ksxl = stuInfo.ksxl; + this.wayno = Number(stuInfo.ksxl); + this.xldm = stuInfo.xldm; + this.kslx = stuInfo.kslx; } // 获取扣分代码信息 async initMarkRules(markRules ?: MarkRule[]) { - const markRuleParams = markRules || (await getSyncData('MA_MARKRULE') as MarkRule[]) + const markRuleParams = markRules || (await GetSyncData('MA_MARKRULE') markRuleParams.forEach(mark => { const tempObj = { @@ -263,25 +279,23 @@ struct Index { // 获取sysset表信息 async initSysset(sysset?: SYSSET[]) { - const syssetParams = sysset || await getSyncData('MA_SYSSET') - //@ts-ignore + const syssetParams: MASYSSETTableType[] = sysset || await GetSyncData('MA_SYSSET') const serialNumberArr = syssetParams.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 { isTrajectoryOpen } = judgeConfig const syssetJudgeConfigArr = [] - //@ts-ignore syssetParams.forEach((sys) => { - if (isTrajectoryOpen) { + if (judgeConfig.isTrajectoryOpen) { sys.v_no = sys.key; sys.v_name = sys.name; sys.v_value = sys.value } - const { v_no, v_value } = sys; - const v_no_num = v_no * 1; - const value = decodeURIComponent(v_value) + // const { v_no, v_value } = sys; + const v_no_num = sys.v_no * 1; + const value = decodeURIComponent(sys.v_value) if (v_no_num >= 10 && v_no_num <= 900) { syssetJudgeConfigArr.push({ key: v_no_num, value: value, @@ -305,16 +319,16 @@ struct Index { // } //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) - if (sys.v_no == '364' && sys.v_value == 2) { - let currentParams: any = router.getParams(); - const { sczb, kfdm } = currentParams; - kfdm.forEach(kf => { - const { xmdm, kfdm } = kf - const currentKf = this.markRuleListObj[`${xmdm}_${kfdm}`]; + if (sys.v_no == '364' && sys.v_value == "2") { + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + // const { sczb, kfdm } = currentParams; + currentParams.kfdm.forEach(kf => { + // const { xmdm, kfdm } = kf + const currentKf = this.markRuleListObj[`${kf.xmdm}_${kf.kfdm}`]; const currentProject = this.projectsObj[xmdm] // 过滤考前绕车一周上车准备的扣分 - if (sczb == 1 && xmdm == '1') { + if (currentParams.sczb == "1" && xmdm == '1') { return } @@ -343,25 +357,24 @@ struct Index { } //初始化systemParam表 - async initSystemParam(sysParam?: SYSTEMPARMARR[]) { - const systemParms: any = sysParam || await getSyncData('MA_SYSTEMPARM') - console.info('surenjun => systemParms', JSON.stringify(systemParms)); + async initSystemParam(sysParam?: MA_SYSTEMPARMType[]) { + let systemParms: MA_SYSTEMPARMType[] = sysParam || await GetSyncData('MA_SYSTEMPARM') - let currentParams: any = router.getParams(); - const { carName, carType, examSubject } = this; + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + // const { carName, carType, examSubject } = this; //小车车型列表 const sCarTypes = ['C1', 'C2', 'C5'] if (this.singlePlay) { - this.wayno = currentParams.wayno || 1; + this.wayno = Number(currentParams.wayno) || 1; } //真实监管下发的项目 let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item); console.info('surenjun kStringArr', JSON.stringify(kStringArr)) let isInExam = kStringArr.length > 0; - const { isTrajectoryOpen } = judgeConfig + // const { isTrajectoryOpen } = judgeConfig let carNo = '', allItems = []; systemParms.forEach((systemParm) => { - if (isTrajectoryOpen) { + if (judgeConfig.isTrajectoryOpen) { systemParm.no1 = systemParm.NO1 + ''; systemParm.no2 = systemParm.NO2 + ''; systemParm.no3 = systemParm.NO3 + ''; @@ -369,41 +382,41 @@ struct Index { systemParm.txt2 = systemParm.TXT2; systemParm.txt3 = systemParm.TXT3; } - const { no1, no2, no3, } = systemParm; + // const { no1, no2, no3, } = systemParm; const txt1 = decodeURI(systemParm.txt1) const txt2 = decodeURI(systemParm.txt2) //获取当前考车的no2 - if (no1 == 3 && no3 == 1) { - if (txt1 === carName) { - carNo = no2 + if (systemParm.no1 == "3" && systemParm.no3 == "1") { + if (txt1 === this.carName) { + carNo = systemParm.no2 this.carlist = carNo } } //获取及格分数线 - if (no1 == 3 && no3 == 3 && carNo === no2) { + if (systemParm.no1 == "3" && systemParm.no3 == "3" && carNo === systemParm.no2) { this.passingScore = Number(txt1) || 0; } //根据车型获取应行驶里程数 - if (no1 == 3 && no3 == 15 && carNo === no2) { + if (systemParm.no1 == "3" && systemParm.no3 == "15" && carNo === systemParm.no2) { this.examMileage = ((decodeURI(systemParm.txt1)) || '').split('^')[0]; } //获取当前考车的考试项目 - if (carNo !== '' && no1 == 3 && no2 == carNo && no3 == 10) { + if (carNo !== '' && systemParm.no1 == "3" && systemParm.no2 == carNo && systemParm.no3 == "10") { allItems = decodeURIComponent(systemParm.txt1).split(',').filter(txt => txt !== '') console.info('surenjun', JSON.stringify(allItems)) } if ( //科目二获取项目 - (examSubject == 2 && allItems.length && no1 == 6 && allItems.includes(no2)) + (this.examSubject == "2" && allItems.length && systemParm.no1 == '6' && allItems.includes(systemParm.no2)) || //科目三获取项目 - (examSubject == 3 && no1 == 6) + (this.examSubject == "3" && systemParm.no1 == "6") ) { const name = decodeURI(systemParm.txt1) //小车过滤掉 夜间模拟行驶 - if (sCarTypes.includes(carType) && name === '夜间行驶') { + if (sCarTypes.includes(this.carType) && name === '夜间行驶') { return } @@ -419,17 +432,17 @@ struct Index { //项目开始数据是否上传过 isUpload: false, } - this.projectsObj[no2*1] = currentProject + this.projectsObj[systemParm.no2*1] = currentProject this.projectsCenterObj[txt2] = currentProject this.projects.push(currentProject); //真实监管下发考试项目 if (isInExam && !(kStringArr.includes(txt2) || kStringArr.includes(no2 + ''))) { console.info('surenjun =>', txt2) - console.info('surenjun => no2', no2) - this.projectsObj[no2*1].type = '3' - this.projectsObj[no2*1].isUpload = true - this.projectsObj[no2*1].isEnd = true + 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 @@ -439,9 +452,9 @@ struct Index { } this.systemparmArr.push({ - 'NO1': no1 * 1, - 'NO2': no2 * 1, - 'NO3': no3 * 1, + 'NO1': Number(systemParm.no1), + 'NO2': Number(systemParm.no2), + 'NO3': Number(systemParm.no3), 'TXT1': decodeURIComponent(systemParm.txt1), 'TXT2': decodeURIComponent(systemParm.txt2), 'TXT3': decodeURIComponent(systemParm.txt3), @@ -461,14 +474,12 @@ struct Index { // 获取场地设备信息 async initCDSBInfo() { - const cdsbParams = await getSyncData('MA_CDSBINFO') + const cdsbParams: MA_CDSBINFOType[] = await GetSyncData('MA_CDSBINFO') //只记录考试项目的模型 const projectsObj = this.projectsObj - //@ts-ignore cdsbParams.forEach((cdsb) => { const key = decodeURI(cdsb.itemsno); const newKey = key.split('~').join('_') - //@ts-ignore const xmdm = key.split('~')[0] * 1 if (projectsObj[xmdm]) { this.cdsbInfoObj[newKey] = { @@ -486,16 +497,14 @@ struct Index { // 获取itemInfo表信息 async initItemInfo() { - const infoParams = await getSyncData('MA_ITEMINFO'); + const infoParams: MA_ITEMINFOType[] = await GetSyncData('MA_ITEMINFO'); const carlist = this.carlist; const projectsObj = this.projectsObj - //@ts-ignore infoParams.forEach((info) => { const key = decodeURI(info.itemsno); const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist).split(',') || []); const newKey = key.split('~').join('_') - //@ts-ignore - const xmdm = key.split('~')[0] * 1 + const xmdm = Number(key.split('~')[0]) if (projectsObj[xmdm] && (carlistArr.length == 0 || carlistArr.includes(carlist))) { this.itemInfoObj[newKey] = { modelKey: newKey, @@ -510,10 +519,10 @@ struct Index { async initJudge() { const judge = new Judge(this); await judge.onJudgeFn(async (judgeData) => { - const { xmmcStr, carztStr, kfArr } = judgeData; - this.xmmcStr = xmmcStr; - this.carztStr = carztStr; - this.kfArr = kfArr; + // const { xmmcStr, carztStr, kfArr } = judgeData; + this.xmmcStr = judgeData.xmmcStr; + this.carztStr = judgeData.carztStr; + this.kfArr = judgeData.kfArr; }); return judge } @@ -521,12 +530,11 @@ struct Index { // 断点续考判断 async goDdxkItems() { const judgeConfigObj = this.judgeConfigObj - const examSubject = this.examSubject //科目二强制开始断点续考 - if (judgeConfigObj['432'] != 0 || examSubject == 2) { + if (judgeConfigObj['432'] != 0 || this.examSubject == "2") { //断点续考判断 - let currentParams: any = router.getParams(); + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; const examItems: string = currentParams?.examItems; // 2024-01-03 16:29:26;0;20300,;2,4^2,4;null; if (examItems !== '' && examItems !== undefined) { @@ -535,7 +543,7 @@ struct Index { const startTime = examItemsArrs[0] const ddxkKsxmArr = examItemsArrs[2]?.split(',').filter(item => item) || [] const ddxkKfArr = examItemsArrs[3]?.split('^').filter(item => item) || [] - if (judgeConfigObj['432'] == 2 || examSubject == 2) { + if (judgeConfigObj['432'] == 2 || this.examSubject == "2") { //TODO 带项目带里程 if (ddxkKsxmArr?.length) { //断点续考 @@ -561,7 +569,6 @@ struct Index { this.kfArr.push({ //扣分项目名称 xmmcStr: currentProject.name, - //@ts-ignore xmdm, desc: currentKf.markshow, score: currentKf.markreal, @@ -581,49 +588,35 @@ struct Index { // 初始化mapPoint表 async initMapPoint() { - const pointParams = await getSyncData('MA_MAP_POINT') - //@ts-ignore - pointParams.forEach(point => { - const { - point_no, - gps_e, - gps_n, - point_no_f, - point_type, - road_code, - gps_e_Location, - gps_n_Location, - f_gps_e, - f_gps_n, - passed - } = point; + const pointParams: MA_MAP_POINTType[] = await GetSyncData('MA_MAP_POINT') + pointParams.forEach(item => { + this.mapPointArr.push({ - point_no: point_no * 1, - gps_e: gps_e * 1, - gps_n: gps_n * 1, - point_no_f: point_no_f * 1, - point_type: point_type * 1, - road_code, - gps_e_Location: (gps_e_Location || 0) * 1, - gps_n_Location: (gps_n_Location || 0) * 1, - f_gps_e: f_gps_e * 1, - f_gps_n: f_gps_n * 1, - passed: passed * 1 + point_no: Number(item.point_no), + gps_e: Number(item.gps_e), + gps_n: Number(item.gps_n), + point_no_f: Number(item.point_no_f), + point_type: Number(item.point_type), + road_code: item.road_code, + gps_e_Location: Number(item.gps_e_location), + gps_n_Location: Number(item.gps_n_location), + f_gps_e: Number(item.f_gps_e), + f_gps_n: Number(item.f_gps_n), + passed: Number(item.passed) }) }) } // 初始化mapPointItem表 async initMapPointItem() { - const pointItemPoints = await getSyncData('MA_MAP_POINT_ITEM'); - //@ts-ignore - pointItemPoints.forEach(itemPoint => { - const { point_no, itemno, itemno1, subname } = itemPoint + const pointItemPoints: MA_MAP_POINT_ITEMType[] = await GetSyncData('MA_MAP_POINT_ITEM'); + pointItemPoints.forEach(item => { + // const { point_no, itemno, itemno1, subname } = itemPoint this.mapPointItemArr.push({ - point_no: point_no * 1, - itemno: itemno * 1, - itemno1: itemno1 * 1, - subname + point_no: Number(item.point_no), + itemno: Number(item.itemno), + itemno1: Number(item.itemno1), + subname: item.subname }) }) } diff --git a/entry/src/main/ets/pages/compontents/FaceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets index 550da4a8..fc88b00a 100644 --- a/entry/src/main/ets/pages/compontents/FaceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -193,7 +193,8 @@ export default struct FaceCompare { carNo: this.carInfo.carNo, placeId: this.carInfo.examinationRoomId } - globalThis.udpClient2.sendMsgExt(param, this.context) + // TODO UPD缺失 + // globalThis.udpClient2.sendMsgExt(param, this.context) } async faceComparFn() { @@ -252,7 +253,8 @@ export default struct FaceCompare { this.callBackFlag = true } } - globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context) + // UDP缺失 + // globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param, this.context) clearInterval(this.interval) this.interval = setInterval(() => { if (this.callBackFlag) { @@ -262,35 +264,37 @@ export default struct FaceCompare { carNo: this.carInfo.carNo, placeId: this.carInfo.examinationRoomId, } - globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param2, this.context) + // TODO UDP缺失 + // globalThis.udpClient2 && globalThis.udpClient2.sendMsgExt(param2, this.context) } }, 1000) - globalThis.udpClient2.setMsgCallBack((val) => { - if (AppStorage.get('statue') != 3) { - return - } - if (val.id == '48') { - if (val.body[13] == '1') { - this.showFaceCompareFlag = !this.showFaceCompareFlag - this.showFaceCompare = !this.showFaceCompare - this.vocObj && this.vocObj.releasePlayer() - this.faceCompareSucess = 1 - clearInterval(this.interval) - } else if (val.body[13] == '0' && this.callBackFlag) { - AppStorage.setOrCreate('statue', 2) - this.vocObj && this.vocObj.playAudio({ - type: 1, - name: 'face_chekc_fail.wav' - }) - } - } - }) + // TODO UDP缺失 + // globalThis.udpClient2.setMsgCallBack((val) => { + // if (AppStorage.get('statue') != 3) { + // return + // } + // if (val.id == '48') { + // if (val.body[13] == '1') { + // this.showFaceCompareFlag = !this.showFaceCompareFlag + // this.showFaceCompare = !this.showFaceCompare + // this.vocObj && this.vocObj.releasePlayer() + // this.faceCompareSucess = 1 + // clearInterval(this.interval) + // } else if (val.body[13] == '0' && this.callBackFlag) { + // AppStorage.setOrCreate('statue', 2) + // this.vocObj && this.vocObj.playAudio({ + // type: 1, + // name: 'face_chekc_fail.wav' + // }) + // } + // } + // }) } async getVideoConfig() { console.log('faceEnterIn') - this.vocObj = new voiceService(async (status: string, val: string, next) => { + this.vocObj = new voiceService(async (status: string, val: string) => { if (status == 'idle') { if (val == 'face_check.mp3' || val == 'face_fail.mp3') { if (this.times >= 3) { diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ets similarity index 96% rename from entry/src/main/ets/pages/judgeSDK/judge.ts rename to entry/src/main/ets/pages/judgeSDK/judge.ets index 35b678f7..bb3ab97d 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -11,7 +11,6 @@ import FileUtil from '../../common/utils/File'; import FileLog from './utils/fileLog'; import JudgeTask from './utils/judgeTask'; import { judgeConfig } from './utils/judgeConfig'; -import { uploadExamProgressData, writeObjectOut } from '../../api/judge'; import UsbService from '../../service/usbService'; import { KF, LANE } from '../judgeSDK/api/judgeSDK.d'; import { endRecordVideo, saveStartRecordVideo } from '../../service/videoService'; @@ -53,50 +52,11 @@ import { examJudgeSoundEnd, examJudgeVersion } from './api/index'; -import { getSyncData, upDateTableByArray } from '../../common/service/initable'; -import App from '@system.app'; +import { writeObjectOut } from '../../api/judge'; const judgeTag = 'SURENJUN_JUDGE' export default class Judge { - // 过程照片拍照 - getPhoto = async (empty?: boolean) => { - const singlePlay = AppStorage.get('singlePlay') - //单机模式返回空照片 - if (singlePlay) { - return '' - } else { - const { filePhoto } = this; - const photoBase64 = await filePhoto.getPhoto(); - console.info(judgeTag, '拍照完成') - return photoBase64 - } - } - //人工操作项目 - public setJudgeItem = async (itemno, type: 1 | 2) => { - const { fileLog } = this; - await examJudgeArtificialItem(itemno * 1, type); - await fileLog.setExamJudgeData({ - method: 'examJudgeArtificialItem', - itemno: itemno * 1, - type - }) - console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`) - } - //人工扣分 - public setJudgeMark = async (itemno, serial, type = 1) => { - const { fileLog } = this - await examJudgeArtificialMark(itemno * 1, serial, type); - console.info(judgeTag, `进入人工扣分-${itemno}-${serial}`) - await fileLog.setExamJudgeData({ - method: 'examJudgeArtificialMark', - itemno: itemno * 1, - serial, - type - }) - - console.info(judgeTag, `人工扣分-${itemno}-${serial}`) - } // 断网数据补传 uploadDisConnectData = async () => { const { isJudgeDisConnect, fileLog, fileUtil } = this; @@ -113,7 +73,7 @@ export default class Judge { } //上传无锡所过程数据 uploadProgressData = async () => { - const carInfo=AppStorage.get('carInfo') + const carInfo = AppStorage.get('carInfo') const { judgeUI, fileUtil, fileLog } = this; const { idCard, startFullTime } = judgeUI const { carId, examinationRoomId } = carInfo @@ -165,7 +125,7 @@ export default class Judge { } // 处理特殊参数配置 handleSEP = async (code: number) => { - const carInfo=AppStorage.get('carInfo') + const carInfo = AppStorage.get('carInfo') const { judgeUI:{ judgeConfigObj @@ -234,50 +194,39 @@ export default class Judge { return true } } - // 处理udp plc信号 - handleUdp = async (msg) => { - console.info('plc信号', msg) - const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this - const stachArr = msg.split(',') - if (stachArr[0] != '#DN_GD' || isUdpEnd) { - return - } - const plcData = await getPlcData(msg); - // 4.过程数据 - await fileLog.setExamJudgeData(plcData) - //检测到有无锡所设备接入,需要发送特定的数据,供检测 - if (usbService.isWXUSBDevice) { - const str = await senorToWXDataStr(msg); - usbService.sendUSB(str) - } - // this.judgeUI.isDwztRight = (plcData.gps.dwzt == 4 && plcData.gps.jdzt == 3); - const param350 = judgeUI.judgeConfigObj['350'] - //@ts-ignore - 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 暂时关闭差分检测异常 - // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); - if (!isExamEnd) { - await examJudgeRealExam(plcData) - } - let udpIndex = AppStorage.get('udpIndex') as number; - let [prevJd, preWd] = [0, 0] - if (udpIndex % 5 === 0 && !isUdpEnd) { - const judgeUdp = globalThis.judgeUdp - const bytes = await this.getMessageHeartbeat(isExamEnd); - judgeUdp.send(bytes) - } - AppStorage.setOrCreate('udpIndex',udpIndex++) - } private fileLog - private filePath + //人工扣分 + public setJudgeMark = async (itemno, serial, type = 1) => { + await examJudgeArtificialMark(itemno * 1, serial, type); + console.info(judgeTag, `进入人工扣分-${itemno}-${serial}`) + await this.fileLog.setExamJudgeData({ + method: 'examJudgeArtificialMark', + itemno: itemno * 1, + serial, + type + }) + + console.info(judgeTag, `人工扣分-${itemno}-${serial}`) + } + //人工操作项目 + public setJudgeItem = async (itemno: number, type: 1 | 2) => { + // const { fileLog } = this; + await examJudgeArtificialItem(itemno * 1, type); + await this.fileLog.setExamJudgeData({ + method: 'examJudgeArtificialItem', + itemno: itemno * 1, + type + }) + 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 + private avPlayer: VoiceAnnounce private carztStr: string private rmndg: 0 | 1 private mndgStr: string | undefined @@ -293,6 +242,18 @@ export default class Judge { 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 @@ -322,7 +283,7 @@ export default class Judge { h: hxj || 1, }) //@ts-ignore - const distanceClass=AppStorage.get('distanceClass') + const distanceClass = AppStorage.get('distanceClass') distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) } this.prevJd = tJD; @@ -483,13 +444,47 @@ export default class Judge { this.plcStr = plc; this.mndgStr = ''; this.rmndg = 0; - AppStorage.setOrCreate('msgStr',plc) + AppStorage.setOrCreate('msgStr', plc) return tempData } + // 处理udp plc信号 + handleUdp = async (msg) => { + console.info('plc信号', msg) + // const { fileLog, getPlcData, usbService, isUdpEnd, isExamEnd, judgeUI } = this + const stachArr = msg.split(',') + if (stachArr[0] != '#DN_GD' || this.isUdpEnd) { + return + } + const plcData = await this.getPlcData(msg); + // 4.过程数据 + await this.fileLog.setExamJudgeData(plcData) + //检测到有无锡所设备接入,需要发送特定的数据,供检测 + if (this.usbService.isWXUSBDevice) { + const str = await senorToWXDataStr(msg); + this.usbService.sendUSB(str) + } + const param350 = 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 暂时关闭差分检测异常 + // await this.checkDwzt(plcData.gps.dwzt,plcData.gps.jdzt); + if (!this.isExamEnd) { + await examJudgeRealExam(plcData) + } + let udpIndex = AppStorage.get('udpIndex') as number; + let [prevJd, preWd] = [0, 0] + if (udpIndex % 5 === 0 && !this.isUdpEnd) { + // TODO UPD缺失 + // const judgeUdp = globalThis.judgeUdp + // const bytes = await this.getMessageHeartbeat(this.isExamEnd); + // judgeUdp.send(bytes) + } + AppStorage.setOrCreate('udpIndex', udpIndex++) + } // 处理轨迹plc信号 handleTrajectoryUdp = async (strArr) => { - const { fileLog, setJudgeItem, setJudgeMark, endExam } = this; + // const { fileLog, setJudgeItem, setJudgeMark, endExam } = this; let num = 2; const judgeTimer = setInterval(async () => { const msgStr = strArr[num]; @@ -508,20 +503,20 @@ export default class Judge { this.judgeUI.dw = Math.floor(msg?.sensor?.dw) + '' this.plcData = msg // this.judgeUI.isDwztRight = msg.gps.dwzt == 4; - AppStorage.setOrCreate('msgStr','') + AppStorage.setOrCreate('msgStr', '') if (msg.method === 'examJudgeArtificialItem') { - setJudgeItem(msg.itemno, msg.type) + this.setJudgeItem(msg.itemno, msg.type) } if (msg.method === 'examJudgeArtificialMark') { - setJudgeItem(msg.itemno, msg.serial) + this.setJudgeItem(msg.itemno, msg.serial) } await examJudgeRealExam(msg) - const bytes = await this.getMessageHeartbeat(); - bytes && globalThis.judgeUdp.send(bytes) + // const bytes = await this.getMessageHeartbeat(); + // bytes && globalThis.judgeUdp.send(bytes) }, 200) - - globalThis.judgeTimer = judgeTimer; + // TODO 定时器缺失 + // globalThis.judgeTimer = judgeTimer; } //当前科目二的考试项目 private currentKm2ItemsObj: any @@ -764,7 +759,6 @@ export default class Judge { ...km3Config, } } - // 获取开始考试数据 getJudgeBeginData = async () => { const examinerInfo = AppStorage.get('examinerInfo') @@ -825,7 +819,6 @@ export default class Judge { console.info(judgeTag, '5.获取开始考试数据完成') return beginInfo } - //处理评判过程回调 handleRealExam = async (strData, callBack) => { let examData: EXAMDATA = JSON.parse(strData); @@ -997,7 +990,6 @@ export default class Judge { judgeUI.projectsObj = deepClone(copyProjectsObj); } } - // 更改考试状态 goVoiceAnnounce = async (event, xmdm, kf, xmjs, ksjs, xmxh) => { const { @@ -1119,13 +1111,13 @@ export default class Judge { case 5: console.info(judgeTag, '考试结束') //关闭录像 - const singlePlay=AppStorage.get('singlePlay') as boolean + const singlePlay = AppStorage.get('singlePlay') as boolean if (!singlePlay) { await endRecordVideo(this.videoData) } judgeTask.addTask(async () => { console.info(judgeTag, '考试结束 start') - AppStorage.setOrCreate('isJudge',false) + AppStorage.setOrCreate('isJudge', false) await handEndExam(ksjs) }) clearInterval(globalThis.judgeTimer) @@ -1144,7 +1136,6 @@ export default class Judge { await checkExamIsEnd() } } - // 考试扣分 pointsDedute = async (ksxm, kf) => { const carInfo = AppStorage.get('carInfo'); @@ -1196,7 +1187,6 @@ export default class Judge { console.info(judgeTag, '项目扣分 end') promptWxCode('17C53', code) } - // 评判语音提示 goJudgeVoice = async (sound: SOUND) => { const { avPlayer, fileLog } = this; @@ -1219,7 +1209,6 @@ export default class Judge { avPlayer.playAudio([`voice/${code[0]}.mp3`]) } } - // 处理考试结束 public handEndExam = async (ksjs: KSJS) => { this.judgeUI.loadingPopupVisible = true; @@ -1277,7 +1266,6 @@ export default class Judge { }); } - // 考试结束 public endExam = async (isManual?: Boolean) => { const carInfo = AppStorage.get('carInfo'); @@ -1448,13 +1436,11 @@ export default class Judge { } } - // 当前项目转换 getDqxmStr = (type) => { const projectsObj = this.judgeUI.projectsObj return projectsObj[type]?.abbreviation || '通用评判' } - // 扣分项目转换 getKfStr = (code) => { const markRuleListObj = this.judgeUI.markRuleListObj; @@ -1467,7 +1453,6 @@ export default class Judge { kfxh: thisMark.kfxh } } - // 消息心跳发送 getMessageHeartbeat = async (isEnd?: Boolean) => { const carInfo = AppStorage.get('carInfo'); @@ -1590,7 +1575,6 @@ export default class Judge { fileLog.setFourAndOneLogDataBytes(tempArr.toString()); return Array2Byte(tempArr) } - //获取场地序号 getSbxh = (ksxm, xmxh) => { const { judgeUI } = this; @@ -1608,7 +1592,6 @@ export default class Judge { const sbxh = currentCdsb.sbbh || '0000000000' return sbxh } - getSbbm = (ksxm, xmxh) => { const { judgeUI } = this; const { cdsbInfoObj, projectsObj, examSubject } = judgeUI; @@ -1625,7 +1608,6 @@ export default class Judge { const sbxh = currentCdsb.sbbm || '00000000' return sbxh } - // 中心所有项目转换 getTranslateProject = () => { const { examSubject } = this.judgeUI; @@ -1656,13 +1638,11 @@ export default class Judge { } return arr } - // 获取考试项目详情 getProjectInfo = (projectCode) => { const judgeUI = this.judgeUI; return judgeUI.projectsObj[projectCode] } - // 获取模型数据 getModelData = (modelName) => { const modelPath = this.modelPath @@ -1670,7 +1650,6 @@ export default class Judge { const modelData = fileModel.getModelContent(modelPath, modelName); return modelData } - // 统计必考项目、所有项目、已考数量 setCountItems = async () => { const carInfo = AppStorage.get('carInfo'); @@ -1702,7 +1681,6 @@ export default class Judge { this.judgeUI.isRequiredProjectsEnd = (projectNum - endProjectsNum === 0) this.judgeUI.isAllProjectsEnd = (allProjectNum - allEndProjectsNum === 0) } - // 检测差分状态 checkDwzt = async (type) => { const { avPlayer } = this; @@ -1735,7 +1713,6 @@ export default class Judge { break; } } - closeAllFiles = () => { setTimeout(() => { this.fileLog.closeAllFiles() @@ -1784,10 +1761,10 @@ export default class Judge { //相关评判初始化只做一次 if (!isJudgeInitBool) { const tempJudge = await examJudgeInit(initInfo); - AppStorage.setOrCreate('isJudgeInitBool',true) + AppStorage.setOrCreate('isJudgeInitBool', true) console.info(judgeTag, '4.评判初始化完成') } - AppStorage.setOrCreate('isJudge',true) + AppStorage.setOrCreate('isJudge', true) // 2.评判过程回调 await examJudgeSetRealExamCallback(async (strData, len) => { await fileLog.setExamJudgeCallbackData(strData)