diff --git a/entry/oh-package-lock.json5 b/entry/oh-package-lock.json5 index d5892e3..3f4c904 100644 --- a/entry/oh-package-lock.json5 +++ b/entry/oh-package-lock.json5 @@ -1,5 +1,5 @@ { - "lockfileVersion": 1, + "lockfileVersion": 2, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": {}, "packages": {} diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index de951f8..87f6339 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -304,6 +304,7 @@ export struct JudgePage { } tempObj.markserial = mark.markserial Reflect.set(this.markRuleListObj, `${mark.itemno}_${mark.markserial}`, tempObj) + dConsole.log(JudgeTag, 'markRuleListObj' + JSON.stringify(this.markRuleListObj)) }) } diff --git a/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets b/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets index 4d49e0c..d8cfcd0 100644 --- a/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/LargeJudgeBusiness.ets @@ -8,6 +8,7 @@ import { ItemInfo, ItemInfos, JudgeBeginObj, + JudgeCallBackData, JudgeInitObj, JudgeKFXM, JudgeKSXM, @@ -15,28 +16,17 @@ import { MAPITEMPOINTITEM, MAPPOINT, MarkRule, - ProcessDataEnumType, + Project, ProjectInfo, + ProjectInfos, RouteParamsType, SyssetConfig, - SYSTEM_PARAM, - Project, - ProjectInfos, - JudgeCallBackData, - KmItem + SYSTEM_PARAM } from '../../model'; import common from '@ohos.app.ability.common'; import { dConsole } from '../../utils/LogWorker'; -import { - examJudgeBeginExam, - examJudgeInit, - examJudgeSetLogCallback, - examJudgeSetPerformCallback, - examJudgeSetRealExamCallback, - examJudgeVersion -} from './JudgeSDKUtils'; +import { examJudgeVersion } from './JudgeSDKUtils'; import JudgeBusiness from './JudgeBusiness'; -import { saveStartRecordVideo } from '../../utils/Video'; import router from '@ohos.router'; import { GetModelData } from './utils'; import { BaseJudge, BaseJudgeImpl, GetSysSetResult } from './BaseJudgeBussines'; @@ -50,129 +40,6 @@ export class LargeJudge extends BaseJudge implements BaseJudgeImpl { private mockLight: boolean = false private mode: number = 1 - private async GetJudgeBeginData(projects: Project[], carType: string, kssycs: string, isDdxk: boolean, ddxkTime: number, projectsCenterObj: Object, ddxkKsxmArr: string[], ddxkKfArr: string[], passingScore: number, wayno: number, name: string, lsh: string, idCard: string, isExam: boolean) { - const examinerInfo = AppStorage.get('examinerInfo') - const examinerName = examinerInfo?.name || "" - let currentParams: RouteParamsType = router.getParams() as RouteParamsType; - const sczb = currentParams.sczb; - const kfdm = currentParams.kfdm; - const ksxm: JudgeKSXM[] = projects.map(project => { - const temp: JudgeKSXM = { - xmdm: Number(project.projectCode), xmxh: '' - } - return temp - }) - const ykxm: number[] = (ddxkKsxmArr?.map(projectCenterCode => { - const currentProject: ProjectInfo = Reflect.get(projectsCenterObj, projectCenterCode) - return Number(currentProject.projectCode) - })) || []; - const kfxm: JudgeKFXM[] = isDdxk ? (ddxkKfArr?.map(kf => { - return { - xmdm: Number(kf.split(',')[0]), kfdm: kf.split(',')[1] - } as JudgeKFXM - })) : [] - const beginInfo: JudgeBeginObj = { - kgid: '012', - kgxm: decodeURI(examinerName || ''), - exam: isExam ? 1 : 0, - //是否回放 - replay: 0, - //生成的轨迹文件 - track: '', - xm: name, - sex: 0, - kslsh: lsh, - sfzmhm: idCard, - ksyy: '', - kscx: carType, - kkcs: Number(kssycs) || 2, - sfyk: 0, - ykkkcs: 1, - wayno: Number(wayno), - czlx: 0, - kskssj: await systemDateTime.getCurrentTime(), - passing: Number(passingScore), - ksxm, - //断点续考 - ddxk: isDdxk ? 1 : 0, - ddkssj: ddxkTime || 0, - ykxm, - kfxm, - yklc: 0, - special: [], - sczb: (sczb === undefined || sczb == '0') ? 0 : 1, - sczbkf: kfdm, - dmndg: this.mockLight, - mfxx: this.mode === 5, - mfxxn: this.mode === 3 || this.mode === 4 - } - dConsole.info(JudgeTag, '5.获取开始考试数据完成') - return beginInfo - }; - - private async GetJudgeInitData(context: common.UIAbilityContext, markRuleListObj: object, carType: string, carName: string, systemparmArr: SYSTEM_PARAM[], carinfoArr: CAR_INFO[], examSubject: string, itemInfoObj: ItemInfos, judgeConfig: SyssetConfig[], carlist: string, mapPointArr: MAPPOINT[], mapPointItemArr: MAPITEMPOINTITEM[]) { - const carInfo = AppStorage.get('carInfo'); - const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3' - - let allitems: ItemInfo[] = []; - if (examSubject == '2' && itemInfoObj) { - allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { - const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); - const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context) - const temp: ItemInfo = { - xmdm: cdsb?.xmdm || 0, - xmxh: cdsb?.xmxh || "", - model: model || "" - } - return temp - }) - } - - //获取版本号 - const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => { - const current: MarkRule = Reflect.get(markRuleListObj, ruleKey) - return current - }) - const initInfo: JudgeInitObj = { - sdkver: await examJudgeVersion(), - appver: AppStorage.get('baseInfo')?.version || "", - kskm: Number(carInfo?.examSubject || "2"), - kchp: carInfo?.plateNo || "", - kchm: Number(carInfo?.carId || ""), - kscx: carType, - cxcode: '1', - name: carName, - carmodel: GetModelData(`${examType}/${carType}.txt`, context) || "", - allitems, - iteminfo: [], - systemparm: systemparmArr, - mark, - sysset: judgeConfig, - itemInfoObj, - carlist: carlist, - carinfo: carinfoArr, - }; - let km3Config: Km3JudgeInitConfig = {} - if (examSubject == '3') { - km3Config = { - map_point: mapPointArr, - map_point_item: mapPointItemArr, - //科目三暂时为空 - iteminfo: [], - roads: GetModelData('km3/Roads.txt', context) || "", - sharps: GetModelData('km3/Sharps.txt', context) || "" - }; - initInfo.map_point = km3Config.map_point - initInfo.map_point_item = km3Config.map_point_item - initInfo.iteminfo = km3Config.iteminfo - initInfo.roads = km3Config.roads - initInfo.sharps = km3Config.sharps - } - // 获取科目三的评判配置 - dConsole.info(JudgeTag, '3.获取评判初始化数据完成') - return initInfo - }; - public async JudgeInit(judgeUI: JudgePage, that: JudgeBusiness): Promise { const systemParams = await GetSyncData('MA_SYSTEMPARM') let currentParams: RouteParamsType = router.getParams() as RouteParamsType; @@ -472,4 +339,129 @@ export class LargeJudge extends BaseJudge implements BaseJudgeImpl { public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) { super.judgeEnd(judgeUI, that, isManual) }; + + private async GetJudgeBeginData(projects: Project[], carType: string, kssycs: string, isDdxk: boolean, ddxkTime: number, projectsCenterObj: Object, ddxkKsxmArr: string[], ddxkKfArr: string[], passingScore: number, wayno: number, name: string, lsh: string, idCard: string, isExam: boolean) { + const examinerInfo = AppStorage.get('examinerInfo') + const examinerName = examinerInfo?.name || "" + let currentParams: RouteParamsType = router.getParams() as RouteParamsType; + const sczb = currentParams.sczb; + const kfdm = currentParams.kfdm; + const ksxm: JudgeKSXM[] = projects.map(project => { + const temp: JudgeKSXM = { + xmdm: Number(project.projectCode), xmxh: '' + } + return temp + }) + const ykxm: number[] = (ddxkKsxmArr?.map(projectCenterCode => { + const currentProject: ProjectInfo = Reflect.get(projectsCenterObj, projectCenterCode) + return Number(currentProject.projectCode) + })) || []; + const kfxm: JudgeKFXM[] = isDdxk ? (ddxkKfArr?.map(kf => { + return { + xmdm: Number(kf.split(',')[0]), kfdm: kf.split(',')[1] + } as JudgeKFXM + })) : [] + const beginInfo: JudgeBeginObj = { + kgid: '012', + kgxm: decodeURI(examinerName || ''), + exam: isExam ? 1 : 0, + //是否回放 + replay: 0, + //生成的轨迹文件 + track: '', + xm: name, + sex: 0, + kslsh: lsh, + sfzmhm: idCard, + ksyy: '', + kscx: carType, + kkcs: Number(kssycs) || 2, + sfyk: 0, + ykkkcs: 1, + wayno: Number(wayno), + czlx: 0, + kskssj: await systemDateTime.getCurrentTime(), + passing: Number(passingScore), + ksxm, + //断点续考 + ddxk: isDdxk ? 1 : 0, + ddkssj: ddxkTime || 0, + ykxm, + kfxm, + yklc: 0, + special: [], + sczb: (sczb === undefined || sczb == '0') ? 0 : 1, + sczbkf: kfdm, + dmndg: this.mockLight, + mfxx: this.mode === 5, + mfxxn: this.mode === 3 || this.mode === 4 + } + dConsole.info(JudgeTag, '5.获取开始考试数据完成') + return beginInfo + }; + + private async GetJudgeInitData(context: common.UIAbilityContext, markRuleListObj: object, carType: string, carName: string, systemparmArr: SYSTEM_PARAM[], carinfoArr: CAR_INFO[], examSubject: string, itemInfoObj: ItemInfos, judgeConfig: SyssetConfig[], carlist: string, mapPointArr: MAPPOINT[], mapPointItemArr: MAPITEMPOINTITEM[]) { + const carInfo = AppStorage.get('carInfo'); + const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3' + + let allitems: ItemInfo[] = []; + if (examSubject == '2' && itemInfoObj) { + const promiseItems = Reflect.ownKeys(itemInfoObj).map(async cdsbKey => { + const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); + const model = await GetModelData(`${examType}/${cdsb.modelKey}.txt`, context); + const temp: ItemInfo = { + xmdm: cdsb?.xmdm || 0, + xmxh: cdsb?.xmxh || "", + model: model || "" + }; + return temp; + }); + // 等待所有的 Promise 解析完成 + allitems = await Promise.all(promiseItems); + } + + //获取版本号 + const mark: MarkRule[] = Reflect.ownKeys(markRuleListObj).map(ruleKey => { + const current: MarkRule = Reflect.get(markRuleListObj, ruleKey) + return current + }) + const initInfo: JudgeInitObj = { + sdkver: await examJudgeVersion(), + appver: AppStorage.get('baseInfo')?.version || "", + kskm: Number(carInfo?.examSubject || "2"), + kchp: carInfo?.plateNo || "", + kchm: Number(carInfo?.carId || ""), + kscx: carType, + cxcode: '1', + name: carName, + carmodel: await GetModelData(`${examType}/${carType}.txt`, context) || "", + allitems, + iteminfo: [], + systemparm: systemparmArr, + mark, + sysset: judgeConfig, + itemInfoObj, + carlist: carlist, + carinfo: carinfoArr, + }; + let km3Config: Km3JudgeInitConfig = {} + if (examSubject == '3') { + km3Config = { + map_point: mapPointArr, + map_point_item: mapPointItemArr, + //科目三暂时为空 + iteminfo: [], + roads: await GetModelData('km3/Roads.txt', context) || "", + sharps: await GetModelData('km3/Sharps.txt', context) || "" + }; + initInfo.map_point = km3Config.map_point + initInfo.map_point_item = km3Config.map_point_item + initInfo.iteminfo = km3Config.iteminfo + initInfo.roads = km3Config.roads + initInfo.sharps = km3Config.sharps + } + // 获取科目三的评判配置 + dConsole.info(JudgeTag, '3.获取评判初始化数据完成') + return initInfo + }; } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets b/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets index de3cc22..91b6592 100644 --- a/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets +++ b/entry/src/main/ets/pages/Judge/SmallJudgeBusiness.ets @@ -102,17 +102,19 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl { dConsole.log(JudgeTag, "itemInfoObj", itemInfoObj) let allitems: ItemInfo[] = []; if (examSubject == '2' && itemInfoObj) { - allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { + const promiseItems = Reflect.ownKeys(itemInfoObj).map(async cdsbKey => { // const cdsb: CDSBInfo = Reflect.get(itemInfoObj, cdsbKey); - const cdsb: CDSBInfo = Object.entries(itemInfoObj).find((arr: Array) => arr[0] === cdsbKey)![1] - const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context) + const cdsb: CDSBInfo = Object.entries(itemInfoObj).find((arr: Array) => arr[0] === cdsbKey)![1]; + const model = await GetModelData(`${examType}/${cdsb.modelKey}.txt`, context); const temp: ItemInfo = { xmdm: cdsb?.xmdm || 0, xmxh: cdsb?.xmxh || "", model: model || "" - } - return temp - }) + }; + return temp; + }); + // 等待所有的 Promise 解析完成 + allitems = await Promise.all(promiseItems); } //获取版本号 @@ -130,7 +132,7 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl { kscx: carType, cxcode: '1', name: carName, - carmodel: GetModelData(`${examType}/${carType}.txt`, context) || "", + carmodel: await GetModelData(`${examType}/${carType}.txt`, context) || "", allitems, iteminfo: [], systemparm: systemparmArr, @@ -147,8 +149,8 @@ export class SmallJudge extends BaseJudge implements BaseJudgeImpl { map_point_item: mapPointItemArr, //科目三暂时为空 iteminfo: [], - roads: GetModelData('km3/Roads.txt', context) || "", - sharps: GetModelData('km3/Sharps.txt', context) || "" + roads: await GetModelData('km3/Roads.txt', context) || "", + sharps: await GetModelData('km3/Sharps.txt', context) || "" }; initInfo.map_point = km3Config.map_point initInfo.map_point_item = km3Config.map_point_item diff --git a/entry/src/main/ets/pages/Judge/utils.ets b/entry/src/main/ets/pages/Judge/utils.ets index 518d066..4eb9721 100644 --- a/entry/src/main/ets/pages/Judge/utils.ets +++ b/entry/src/main/ets/pages/Judge/utils.ets @@ -11,21 +11,19 @@ import { MarkRule, PLCType, ProcessDataEnumType, - Project, ProjectInfo, ProjectInfos, ProjectRoads, Radar, Vision } from '../../model'; -import { ArrayToByteArray, NumberToByteArray } from '../../utils/Common'; +import { ArrayToByteArray, NumberToByteArray, ReadFileContent } from '../../utils/Common'; import dayTs from '../../utils/Date'; import { dConsole } from '../../utils/LogWorker'; -import FileModel from '../judgeSDK/utils/fileModel'; import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'; import { examJudgeSoundEnd } from './JudgeSDKUtils'; import common from '@ohos.app.ability.common'; -import { JudgeConfig, JudgeTag } from '../../config'; +import { GlobalConfig, JudgeConfig, JudgeTag } from '../../config'; // 中心信号转换 @@ -915,9 +913,12 @@ export const DetectingDifferences = async (type: number, avPlayer: VoiceAnnounce /** * 获取车辆模型 */ -export const GetModelData = (modelName: string, context: common.UIAbilityContext): string => { +export const GetModelData = async (modelName: string, context: common.UIAbilityContext): Promise => { try { - return new FileModel(context).getModelContent(JudgeConfig.modelPath, modelName) || ""; + let path = GlobalConfig.commonFileWriteAddress + "/" + JudgeConfig.modelPath + "/" + modelName + const res = await ReadFileContent(path) + return res || "" + // return new FileModel(context).getModelContent(JudgeConfig.modelPath, modelName) || ""; } catch (e) { // 可根据实际需求,返回空字符串或抛出异常 dConsole.error(JudgeTag, `获取模型数据失败: ${modelName}`, e.message) diff --git a/entry/src/main/ets/utils/Common.ets b/entry/src/main/ets/utils/Common.ets index 80657af..c356c20 100644 --- a/entry/src/main/ets/utils/Common.ets +++ b/entry/src/main/ets/utils/Common.ets @@ -439,3 +439,8 @@ export const GetPhotoBase64 = async (context: common.UIAbilityContext): Promise< } } + +export function GetObjectValue(obj: T, key: string): ESObject { + // 推荐:直接使用索引访问 + return obj[key as keyof T]; +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/SerialPort.ets b/entry/src/main/ets/utils/SerialPort.ets index e940356..09c7b61 100644 --- a/entry/src/main/ets/utils/SerialPort.ets +++ b/entry/src/main/ets/utils/SerialPort.ets @@ -50,7 +50,7 @@ export const InitSerialPortData = * @returns Promise 成功返回发送的字节数,失败返回-1 */ export const SendSerialPortData = (fd: number, data: number[]) => { - console.log(SerialPortTag, "wzj-----发送数据") + // console.log(SerialPortTag, "wzj-----发送数据") return new Promise((resolve, reject) => { HiSerialSDK.SerialSendAsync(fd, data, (value: number) => { console.log(SerialPortTag, "发送数据完成!") diff --git a/entry/src/main/ets/utils/table/Operation.ets b/entry/src/main/ets/utils/table/Operation.ets index d216c17..3c5a6be 100644 --- a/entry/src/main/ets/utils/table/Operation.ets +++ b/entry/src/main/ets/utils/table/Operation.ets @@ -35,8 +35,8 @@ export function SqlInsertTable(tableName: string, data: Array, delFl const values = data.map(item => { const value = columnsData?.filter(column => column !== "id") .map((column) => { - // return `'${Reflect.get(item, column) || ""}'` - return `'${Object.entries(item).find((keyArr: Array) => keyArr[0] === column)?.[1] || ""}'` + return `'${Reflect.get(item, column) || ""}'` + // return `'${Object.entries(item).find((keyArr: Array) => keyArr[0] === column)?.[1] || ""}'` }) .join(",") return `(${value})` diff --git a/entry/src/main/ets/workers/DifferentialCorrection.ets b/entry/src/main/ets/workers/DifferentialCorrection.ets index f9a772b..9df9d2b 100644 --- a/entry/src/main/ets/workers/DifferentialCorrection.ets +++ b/entry/src/main/ets/workers/DifferentialCorrection.ets @@ -81,14 +81,18 @@ function getDataFn(config: EnvironmentConfigurationType) { // TODO // 需要观察 // console.log(WorkerTag, "后置机消息", data) - const res = await SerialPortService.getData() - console.log(SerialPortTag, "档位原始数据", res) - if (res.length > 0) { - const dataArray = data.split(","); - // 替换data的第28位 - dataArray[28] = res[9].toString(); - data = dataArray.join(","); - // console.log(SerialPortTag, "档位", res[9].toString()) + try { + const res = await SerialPortService.getData() + console.log(SerialPortTag, "档位原始数据", res) + if (res.length > 0) { + const dataArray = data.split(","); + // 替换data的第28位 + dataArray[28] = res[9].toString(); + data = dataArray.join(","); + // console.log(SerialPortTag, "档位", res[9].toString()) + } + } catch (err) { + console.error(SerialPortTag, "获取档位信号失败", err) } // console.log(SerialPortTag, "处理完的档位信号", data) workerPort.postMessage( diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 index f76874c..d61f840 100644 --- a/oh-package-lock.json5 +++ b/oh-package-lock.json5 @@ -1,18 +1,20 @@ { - "lockfileVersion": 1, + "lockfileVersion": 2, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { "@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3", "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" }, "packages": { - "@ohos/crypto-js@2.0.3": { - "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har", - "integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==" - }, "@ohos/hypium@1.0.19": { "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", - "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==" + "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", + "registryType": "ohpm" + }, + "@ohos/crypto-js@2.0.3": { + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har", + "integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==", + "registryType": "ohpm" } } } \ No newline at end of file