Compare commits

...

3 Commits

Author SHA1 Message Date
wangzhongjie
afb59d0611 Merge branch 'dev' of http://47.122.70.237:3000/harmony_car/harmony_vehicle_terminal into dev 2025-10-21 14:45:16 +08:00
wangzhongjie
3f08b76e08 fix: 验证润和问题 2025-10-21 14:45:11 +08:00
wangzhongjie
77523adcb2 fix: 串口问题 2025-10-21 14:44:45 +08:00
11 changed files with 178 additions and 177 deletions

View File

@ -1,5 +1,5 @@
{
"lockfileVersion": 1,
"lockfileVersion": 2,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {},
"packages": {}

View File

@ -305,6 +305,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))
})
}

View File

@ -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<ExaminerInfoType>('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<CarInfoType>('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<BaseInfoType>('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<GetSysSetResult> {
const systemParams = await GetSyncData<SYSTEM_PARAM>('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<ExaminerInfoType>('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<CarInfoType>('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<BaseInfoType>('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
};
}

View File

@ -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<string>) => arr[0] === cdsbKey)![1]
const model = GetModelData(`${examType}/${cdsb.modelKey}.txt`, context)
const cdsb: CDSBInfo = Object.entries(itemInfoObj).find((arr: Array<string>) => 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

View File

@ -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<string> => {
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)

View File

@ -452,3 +452,8 @@ export const GetPhotoBase64 = async (context: common.UIAbilityContext): Promise<
}
}
export function GetObjectValue<T>(obj: T, key: string): ESObject {
// 推荐:直接使用索引访问
return obj[key as keyof T];
}

View File

@ -50,7 +50,7 @@ export const InitSerialPortData =
* @returns Promise<number> 成功返回发送的字节数,失败返回-1
*/
export const SendSerialPortData = (fd: number, data: number[]) => {
console.log(SerialPortTag, "wzj-----发送数据")
// console.log(SerialPortTag, "wzj-----发送数据")
return new Promise<number>((resolve, reject) => {
HiSerialSDK.SerialSendAsync(fd, data, (value: number) => {
console.log(SerialPortTag, "发送数据完成!")

View File

@ -9,7 +9,6 @@ import {
} from '../SerialPort';
import Prompt from '@system.prompt';
import { SerialPortTag } from '../../config';
import { EnvironmentConfigurationType } from '../../model';
class serialPortService {
private fd: number = -1
@ -21,11 +20,6 @@ class serialPortService {
private tryCount: number = 0
async init() {
let config: EnvironmentConfigurationType = AppStorage.get<EnvironmentConfigurationType>("EnvironmentConfiguration")!
if (config.manufacturer === "2") {
console.log(SerialPortTag, "更改润和串口端口")
this.serialPort = "/dev/ttyS7"
}
const res = await OpenSerialPort(this.serialPort)
if (res === -1) {
Prompt.showToast({

View File

@ -35,8 +35,8 @@ export function SqlInsertTable(tableName: string, data: Array<RecordType>, 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<string>) => keyArr[0] === column)?.[1] || ""}'`
return `'${Reflect.get(item, column) || ""}'`
// return `'${Object.entries(item).find((keyArr: Array<string>) => keyArr[0] === column)?.[1] || ""}'`
})
.join(",")
return `(${value})`

View File

@ -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(

View File

@ -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"
}
}
}