refactor: 更新类型定义,优化代码可读性

This commit is contained in:
wangzhongjie 2025-04-11 10:14:35 +08:00
parent 2d98914122
commit 323f3447e7
11 changed files with 205 additions and 182 deletions

View File

@ -1,6 +1,18 @@
{ {
"lockfileVersion": 2, "meta": {
"stableOrder": true
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {}, "specifiers": {
"packages": {} "libjudgesdk.so@src/cpp/libJudgeSdk": "libjudgesdk.so@src/cpp/libJudgeSdk"
},
"packages": {
"libjudgesdk.so@src/cpp/libJudgeSdk": {
"name": "libjudgesdk.so",
"version": "1.0.0",
"resolved": "src/cpp/libJudgeSdk",
"registryType": "local"
}
}
} }

View File

@ -112,7 +112,7 @@ export interface CarInfoType {
examinationRoomId?: string; examinationRoomId?: string;
plateNo?: string; plateNo?: string;
carNo?: string; carNo?: string;
examSubject?: string; examSubject: string;
isNeedCheck?: string; isNeedCheck?: string;
udpAddress?: string udpAddress?: string
messagePort?: string messagePort?: string

View File

@ -320,49 +320,49 @@ export type Km3WxXmdmEnum = 40100 | 40200 | 40300 | 40500 | 40700 | 41000
/** 考试过程中所有项目信息**/ /** 考试过程中所有项目信息**/
// export interface ProjectInfos { export interface ProjectInfos {
// 0?: ProjectInfo 0?: ProjectInfo
// 2?: ProjectInfo 2?: ProjectInfo
// 3?: ProjectInfo 3?: ProjectInfo
// 5?: ProjectInfo 5?: ProjectInfo
// 6?: ProjectInfo 6?: ProjectInfo
// 1?: ProjectInfo 1?: ProjectInfo
// 4?: ProjectInfo 4?: ProjectInfo
// 7?: ProjectInfo 7?: ProjectInfo
// 8?: ProjectInfo 8?: ProjectInfo
// 9?: ProjectInfo 9?: ProjectInfo
// 10?: ProjectInfo 10?: ProjectInfo
// 11?: ProjectInfo 11?: ProjectInfo
// 12?: ProjectInfo 12?: ProjectInfo
// 14?: ProjectInfo 14?: ProjectInfo
// 15?: ProjectInfo 15?: ProjectInfo
// 16?: ProjectInfo 16?: ProjectInfo
// 41?: ProjectInfo 41?: ProjectInfo
// } }
// export interface ProjectCenterInfos { export interface ProjectCenterInfos {
// 20100?: ProjectInfo 20100?: ProjectInfo
// 20300?: ProjectInfo 20300?: ProjectInfo
// 20400?: ProjectInfo 20400?: ProjectInfo
// 20600?: ProjectInfo 20600?: ProjectInfo
// 20700?: ProjectInfo 20700?: ProjectInfo
// 40100?: ProjectInfo 40100?: ProjectInfo
// 40200?: ProjectInfo 40200?: ProjectInfo
// 40300?: ProjectInfo 40300?: ProjectInfo
// 40500?: ProjectInfo 40500?: ProjectInfo
// 40700?: ProjectInfo 40700?: ProjectInfo
// 41000?: ProjectInfo 41000?: ProjectInfo
// 41100?: ProjectInfo 41100?: ProjectInfo
// 41200?: ProjectInfo 41200?: ProjectInfo
// 41300?: ProjectInfo 41300?: ProjectInfo
// 41400?: ProjectInfo 41400?: ProjectInfo
// 40600?: ProjectInfo 40600?: ProjectInfo
// 41500?: ProjectInfo 41500?: ProjectInfo
// 41700?: ProjectInfo 41700?: ProjectInfo
// 40400?: ProjectInfo 40400?: ProjectInfo
// 40800?: ProjectInfo 40800?: ProjectInfo
// 40900?: ProjectInfo 40900?: ProjectInfo
// } }
export interface MarkRule { export interface MarkRule {
itemno?: number itemno?: number

View File

@ -96,8 +96,8 @@ export default class Judge {
sharps: this.getModelData('km3/Sharps.txt') sharps: this.getModelData('km3/Sharps.txt')
} }
} }
private context: common.UIAbilityContext private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
private fileLog: FileLog private fileLog?: FileLog
//人工扣分 //人工扣分
public setJudgeMark = async (itemno: string, serial: string, type = 1) => { public setJudgeMark = async (itemno: string, serial: string, type = 1) => {
await examJudgeArtificialMark(Number(itemno), serial, type); await examJudgeArtificialMark(Number(itemno), serial, type);
@ -108,7 +108,7 @@ export default class Judge {
serial, serial,
type type
}) })
await this.fileLog.setExamJudgeData(str) await this.fileLog?.setExamJudgeData(str)
console.info(judgeTag, `人工扣分-${itemno}-${serial}`) console.info(judgeTag, `人工扣分-${itemno}-${serial}`)
} }
//人工操作项目 //人工操作项目
@ -120,17 +120,17 @@ export default class Judge {
itemno: Number(itemno), itemno: Number(itemno),
type type
}) })
await this.fileLog.setExamJudgeData(str) await this.fileLog?.setExamJudgeData(str)
console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`) console.info(judgeTag, `人工评判${type == 1 ? '进入' : '取消'}项目-${itemno}`)
} }
private filePath: string private filePath: string = ""
private totalScore: number private totalScore: number = -1
private prevJd: number = 0 private prevJd: number = 0
private prevWd: number = 0 private prevWd: number = 0
private dwztNum: number = 0 private dwztNum: number = 0
private folderPath: string private folderPath: string = ""
private modelPath: string private modelPath: string = ""
private avPlayer: VoiceAnnounce private avPlayer?: VoiceAnnounce
// 处理特殊参数配置 // 处理特殊参数配置
handleSEP = async (code: number) => { handleSEP = async (code: number) => {
const judgeConfigObj = this.judgeUI.judgeConfigObj const judgeConfigObj = this.judgeUI.judgeConfigObj
@ -140,34 +140,34 @@ export default class Judge {
case 306: case 306:
if (judgeConfigObj[code] == 5) { if (judgeConfigObj[code] == 5) {
//靠边停车 //靠边停车
avPlayer.playAudio(['voice/406001.mp3']) avPlayer?.playAudio(['voice/406001.mp3'])
} }
break; break;
} }
} }
private carztStr: string private carztStr: string
private rmndg: 0 | 1 private rmndg: 0 | 1 = 0
private mndgStr: string | undefined private mndgStr: string | undefined
// 模拟灯光 // 模拟灯光
setMndg = async (mndgStr: string) => { setMndg = async (mndgStr: string) => {
this.mndgStr = mndgStr this.mndgStr = mndgStr
} }
private xmmcStr: string private xmmcStr: string = ""
private xmmcCode: string private xmmcCode: string = ""
private xmmcSingleCode: string private xmmcSingleCode: string = ""
private xmmcEndCode?: string private xmmcEndCode?: string
private xmdm: string | number private xmdm: string | number = ""
private xmxh: string private xmxh: string = ""
private fileModel: FileModel private fileModel?: FileModel
private filePhoto: FilePhoto private filePhoto?: FilePhoto
// 过程照片拍照 // 过程照片拍照
getPhoto = async (empty?: boolean) => { getPhoto = async (empty?: boolean) => {
const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') const singlePlay: boolean = AppStorage.get<boolean>('singlePlay') || false
//单机模式返回空照片 //单机模式返回空照片
if (singlePlay) { if (singlePlay) {
return '' return ''
} else { } else {
const photoBase64 = await this.filePhoto.getPhoto(); const photoBase64 = await this.filePhoto?.getPhoto();
console.info(judgeTag, '拍照完成') console.info(judgeTag, '拍照完成')
return photoBase64 return photoBase64
} }
@ -188,7 +188,7 @@ export default class Judge {
} }
const plcData = await this.getPlcData(msg); const plcData = await this.getPlcData(msg);
// 4.过程数据 // 4.过程数据
await this.fileLog.setExamJudgeData(JSON.stringify(plcData)) await this.fileLog?.setExamJudgeData(JSON.stringify(plcData))
//检测到有无锡所设备接入,需要发送特定的数据,供检测 //检测到有无锡所设备接入,需要发送特定的数据,供检测
// if (this.usbService.isWXUSBDevice) { // if (this.usbService.isWXUSBDevice) {
// const str = await senorToWXDataStr(msg); // const str = await senorToWXDataStr(msg);
@ -202,7 +202,7 @@ export default class Judge {
if (!this.isExamEnd) { if (!this.isExamEnd) {
await examJudgeRealExam(plcData) await examJudgeRealExam(plcData)
} }
let udpIndex = AppStorage.get<number>('udpIndex'); let udpIndex = AppStorage.get<number>('udpIndex') || 0;
if (udpIndex % 5 === 0 && !this.isUdpEnd) { if (udpIndex % 5 === 0 && !this.isUdpEnd) {
// TODO UPD缺失 // TODO UPD缺失
// const judgeUdp = globalThis.judgeUdp // const judgeUdp = globalThis.judgeUdp
@ -212,7 +212,7 @@ export default class Judge {
AppStorage.setOrCreate('udpIndex', udpIndex++) AppStorage.setOrCreate('udpIndex', udpIndex++)
} }
//是否手动结束考试 //是否手动结束考试
private isManual: boolean private isManual: boolean = false
//UDP服务序列号 //UDP服务序列号
private serialIndex: number private serialIndex: number
private fileUtil: FileUtils private fileUtil: FileUtils
@ -222,10 +222,10 @@ export default class Judge {
const judgeUI = this.judgeUI const judgeUI = this.judgeUI
const fileUtil = this.fileUtil const fileUtil = this.fileUtil
const fileLog = this.fileLog const fileLog = this.fileLog
const carId = carInfo.carId const carId = carInfo?.carId || ""
const examinationRoomId = carInfo.examinationRoomId const examinationRoomId = carInfo?.examinationRoomId || ""
const folderPath = fileLog.folderPath const folderPath = fileLog?.folderPath
const base64 = new util.Base64(); const base64 = new util.Base64();
const time = GetCurrentTime(); const time = GetCurrentTime();
const endTime = GetCurrentTime(1) const endTime = GetCurrentTime(1)
@ -258,20 +258,20 @@ export default class Judge {
console.info(judgeTag, '过程数据文件上传 end') console.info(judgeTag, '过程数据文件上传 end')
} }
private judgeTask: JudgeTask private judgeTask: JudgeTask
private tempData: Plc private tempData?: Plc
//实时计算gps经纬度距离 //实时计算gps经纬度距离
handDistance = async () => { handDistance = async () => {
const dwzt = this.tempData.gps.dwzt; const dwzt = this.tempData?.gps?.dwzt || "";
const jdzt = this.tempData.gps.jdzt; const jdzt = this.tempData?.gps?.jdzt || "";
const tJD = convertGpsCoord2(this.tempData.gps.jd) const tJD = convertGpsCoord2(this.tempData?.gps?.jd || 0)
const tWD = convertGpsCoord2(this.tempData.gps.wd) const tWD = convertGpsCoord2(this.tempData?.gps?.wd || 0)
if (this.prevJd && dwzt == 4 && jdzt == 3) { if (this.prevJd && dwzt == 4 && jdzt == 3) {
const distance = await examCalcGpsDistance({ const distance = await examCalcGpsDistance({
jd1: this.prevJd, jd1: this.prevJd,
wd1: this.prevWd, wd1: this.prevWd,
jd2: tJD, jd2: tJD,
wd2: tWD, wd2: tWD,
h: (this.tempData.gps.hxj) || 1, h: this.tempData?.gps?.hxj || 1,
}) })
// const distanceClass = AppStorage.get<DistanceClass>('distanceClass') // const distanceClass = AppStorage.get<DistanceClass>('distanceClass')
// distanceClass?.setTimeData(Number(((distance / 100).toFixed(2)))) // distanceClass?.setTimeData(Number(((distance / 100).toFixed(2))))
@ -324,7 +324,7 @@ export default class Judge {
(param302 != 6 && param302 != 7 && param302 != 8)) { (param302 != 6 && param302 != 7 && param302 != 8)) {
if (param512[7] != 0) { if (param512[7] != 0) {
clearTimeout(this.deductedPopShowTimer) clearTimeout(this.deductedPopShowTimer)
avPlayer.playAudio(['voice/综合评判.mp3']) avPlayer?.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true this.judgeUI.isDeductedPopShow = true
this.judgeUI.defaultTabIndex = 1 this.judgeUI.defaultTabIndex = 1
this.isEndTip = true this.isEndTip = true
@ -350,7 +350,7 @@ export default class Judge {
if (totalScore < passingGrade) { if (totalScore < passingGrade) {
//科目三不合格报靠边停车 //科目三不合格报靠边停车
if (examSubject == '3' && param302 == 1) { if (examSubject == '3' && param302 == 1) {
avPlayer.playAudio([`voice/考试结束.mp3`]); avPlayer?.playAudio([`voice/考试结束.mp3`]);
return return
} }
await examJudgeEndExam() await examJudgeEndExam()
@ -383,7 +383,7 @@ export default class Judge {
if (param512[7] != 0) { if (param512[7] != 0) {
clearTimeout(this.deductedPopShowTimer) clearTimeout(this.deductedPopShowTimer)
this.judgeUI.isDeductedPopShow = false this.judgeUI.isDeductedPopShow = false
avPlayer.playAudio(['voice/综合评判.mp3']) avPlayer?.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true this.judgeUI.isDeductedPopShow = true
this.judgeUI.defaultTabIndex = 1 this.judgeUI.defaultTabIndex = 1
this.isEndTip = true this.isEndTip = true
@ -396,24 +396,24 @@ export default class Judge {
} }
} }
} }
private ksjs: JudgeKSJS private ksjs?: JudgeKSJS
private kfArr: JudgeEventKf[] private kfArr?: JudgeEventKf[]
//所有的科目考试项目(大车&小车) //所有的科目考试项目(大车&小车)
private kmItems: JudgeConfigObjKmItems private kmItems: JudgeConfigObjKmItems
private plcData: Plc private plcData?: Plc
// 获取plc数据 // 获取plc数据
getPlcData = async (plc: string) => { getPlcData = async (plc: string) => {
await this.fileLog.setPlcProgressData(plc) await this.fileLog?.setPlcProgressData(plc)
//plc字符串转化成评判初始化数据 //plc字符串转化成评判初始化数据
const tempData = await plcStrToJson(plc); const tempData = await plcStrToJson(plc);
//模拟灯光回放时刻 //模拟灯光回放时刻
tempData.sensor.rmndg = this.rmndg; tempData.sensor.rmndg = this.rmndg;
//模拟灯灯光灯光项目 //模拟灯灯光灯光项目
tempData.sensor.mndg = this.mndgStr; tempData.sensor.mndg = this.mndgStr || "";
//plc字符串转化成无锡所过程数据 //plc字符串转化成无锡所过程数据
const wuXiDataStr = await plcStrToWXJson(plc) const wuXiDataStr = await plcStrToWXJson(plc)
this.plcData = tempData this.plcData = tempData
await this.fileLog.setExamJudgeWuxiProgressData(wuXiDataStr) await this.fileLog?.setExamJudgeWuxiProgressData(wuXiDataStr)
this.tempData = tempData this.tempData = tempData
this.plcStr = plc; this.plcStr = plc;
this.mndgStr = ''; this.mndgStr = '';
@ -463,13 +463,13 @@ export default class Judge {
private isTrajectoryOpen: boolean; private isTrajectoryOpen: boolean;
//当前科目二的考试项目 //当前科目二的考试项目
// 调代理接口是否断网了 // 调代理接口是否断网了
private isJudgeDisConnect: boolean; private isJudgeDisConnect: boolean = false;
// 断网数据补传 // 断网数据补传
uploadDisConnectData = async () => { uploadDisConnectData = async () => {
if (!this.isJudgeDisConnect) { if (!this.isJudgeDisConnect) {
return return
} }
const folderPath = this.fileLog.folderPath const folderPath = this.fileLog?.folderPath
const examDataStr = await this.fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`); const examDataStr = await this.fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`);
const examDataArr = examDataStr.split('\n'); const examDataArr = examDataStr.split('\n');
for (let examDataStr of examDataArr) { for (let examDataStr of examDataArr) {
@ -488,13 +488,13 @@ export default class Judge {
const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305') const judgeConfig_305: number = Reflect.get(judgeUI.judgeConfigObj, '305')
const drvexam: DrvexamType = { const drvexam: DrvexamType = {
lsh: judgeUI.lsh, lsh: judgeUI.lsh,
kskm: carInfo.examSubject, kskm: carInfo?.examSubject || "2",
ksxm: project.projectCodeCenter, ksxm: project.projectCodeCenter,
sfzmhm: judgeUI.idCard, sfzmhm: judgeUI.idCard,
kchp: encodeURI(carInfo.plateNo), kchp: encodeURI(carInfo?.plateNo || ""),
zpsj: time, zpsj: time,
zp: photoBase64, zp: photoBase64,
cs: Math.floor((judgeConfig_305 == 0 ? plcData.gps.sd : plcData.sensor.cs) * 1.852), cs: Math.floor((judgeConfig_305 == 0 ? (plcData?.gps?.sd || 0) : (plcData?.sensor?.cs || 0)) * 1.852),
ksdd: encodeURI(judgeUI.ksdd) ksdd: encodeURI(judgeUI.ksdd)
} }
const data: RegulatoryInterfaceParams = { const data: RegulatoryInterfaceParams = {
@ -507,14 +507,14 @@ export default class Judge {
if (temp.code === 2300007) { if (temp.code === 2300007) {
this.isJudgeDisConnect = true this.isJudgeDisConnect = true
} }
promptWxCode('17C54', temp.code) promptWxCode('17C54', temp.code || 0)
console.info(judgeTag, '上传照片 end') console.info(judgeTag, '上传照片 end')
} }
private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11] private artSubject3ProjectsCodesArr: number[] = [3, 9, 4, 10, 12, 11]
private lane: LANE = { private lane: LANE = {
road: '', num: 0, count: 0 road: '', num: 0, count: 0
} }
private videoData: RecordHandleType private videoData?: RecordHandleType
private disConnectNum: number = 0; private disConnectNum: number = 0;
//调用监管接口 //调用监管接口
sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => { sendWriteObjectOut: SendWriteObjectOut = async (data, filePath) => {
@ -547,12 +547,12 @@ export default class Judge {
const drvexam: DrvexamType = { const drvexam: DrvexamType = {
lsh: judgeUI.lsh, lsh: judgeUI.lsh,
kskm: carInfo.examSubject, kskm: carInfo?.examSubject || "2",
sfzmhm: judgeUI.idCard, sfzmhm: judgeUI.idCard,
ksxm: project.projectCodeCenter, ksxm: project.projectCodeCenter,
sbxh, sbxh,
ksxl: judgeUI.xldm, ksxl: judgeUI.xldm,
kchp: encodeURI(carInfo.plateNo), kchp: encodeURI(carInfo?.plateNo || ""),
ksdd: encodeURI(judgeUI.ksdd), ksdd: encodeURI(judgeUI.ksdd),
kslx: encodeURI(judgeUI.kslx) || '', kslx: encodeURI(judgeUI.kslx) || '',
kssj: time kssj: time
@ -569,7 +569,7 @@ export default class Judge {
if (temp.code === 2300007) { if (temp.code === 2300007) {
this.isJudgeDisConnect = true; this.isJudgeDisConnect = true;
} }
promptWxCode('17C52', temp.code) promptWxCode('17C52', temp.code || 0)
} }
// 项目结束接口同步 // 项目结束接口同步
endProject = async (ksxm: number) => { endProject = async (ksxm: number) => {
@ -581,14 +581,14 @@ export default class Judge {
const drvexam: DrvexamType = { const drvexam: DrvexamType = {
lsh: judgeUI.lsh, lsh: judgeUI.lsh,
kskm: carInfo.examSubject, kskm: carInfo?.examSubject || "2",
sfzmhm: judgeUI.idCard, sfzmhm: judgeUI.idCard,
ksxm: project.projectCodeCenter, ksxm: project.projectCodeCenter,
sbxh, sbxh,
//TODO 操作类型 1:正常 0:撤销该考试记录 //TODO 操作类型 1:正常 0:撤销该考试记录
czlx: '1', czlx: '1',
ksxl: judgeUI.xldm, ksxl: judgeUI.xldm,
kchp: encodeURI(carInfo.plateNo), kchp: encodeURI(carInfo?.plateNo || ""),
ksdd: encodeURI(judgeUI.ksdd), ksdd: encodeURI(judgeUI.ksdd),
kslx: encodeURI(judgeUI.kslx) || '', kslx: encodeURI(judgeUI.kslx) || '',
jssj: time jssj: time
@ -604,7 +604,7 @@ export default class Judge {
this.isJudgeDisConnect = true; this.isJudgeDisConnect = true;
} }
console.info(judgeTag, '项目结束 end') console.info(judgeTag, '项目结束 end')
promptWxCode('17C55', temp.code) promptWxCode('17C55', temp.code || 0)
} }
// 检测扣分、结束项目时该项目是否开始 // 检测扣分、结束项目时该项目是否开始
checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: JudgeEventKf) => { checkProjectIsStart = async (xmdm: number, currentType: 1 | 2, kf?: JudgeEventKf) => {
@ -613,7 +613,7 @@ export default class Judge {
} }
const judgeUI = this.judgeUI; const judgeUI = this.judgeUI;
const judgeTask = this.judgeTask; const judgeTask = this.judgeTask;
const projectsObj = this.judgeUI.projectsObj const projectsObj: object = this.judgeUI.projectsObj
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm) const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
const isUpload = currentProject.isUpload const isUpload = currentProject.isUpload
@ -637,7 +637,7 @@ export default class Judge {
//扣分补传 //扣分补传
if (currentType == 2) { if (currentType == 2) {
judgeTask.addTask(async () => { judgeTask.addTask(async () => {
await this.pointsDedute(xmdm, kf) await this.pointsDedute(xmdm, kf!)
}, { }, {
isDelay: true isDelay: true
}) })
@ -713,15 +713,17 @@ export default class Judge {
const carName = judgeUI.carName const carName = judgeUI.carName
const systemparmArr = judgeUI.systemparmArr const systemparmArr = judgeUI.systemparmArr
const carinfoArr = judgeUI.carinfoArr 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') { if (judgeUI.examSubject == '2' && itemInfoObj) {
allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => { 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 model = this.getModelData(`${examType}/${cdsb.modelKey}.txt`)
const temp: ItemInfo = { const temp: ItemInfo = {
xmdm: cdsb.xmdm, xmxh: cdsb.xmxh, model xmdm: cdsb?.xmdm||0,
xmxh: cdsb?.xmxh||"",
model:model||""
} }
return temp return temp
}) })
@ -734,14 +736,14 @@ export default class Judge {
}) })
const initInfo: JudgeInitObj = { const initInfo: JudgeInitObj = {
sdkver: await examJudgeVersion(), sdkver: await examJudgeVersion(),
appver: AppStorage.get<BaseInfoType>('baseInfo').version, appver: AppStorage.get<BaseInfoType>('baseInfo')?.version||"",
kskm: Number(carInfo.examSubject), kskm: Number(carInfo?.examSubject||"2"),
kchp: carInfo.plateNo, kchp: carInfo?.plateNo||"",
kchm: Number(carInfo.carId), kchm: Number(carInfo?.carId||""),
kscx: carType, kscx: carType,
cxcode: '1', cxcode: '1',
name: carName, name: carName,
carmodel: this.getModelData(`${examType}/${carType}.txt`), carmodel: this.getModelData(`${examType}/${carType}.txt`)||"",
allitems, allitems,
iteminfo: [], iteminfo: [],
systemparm: systemparmArr, systemparm: systemparmArr,
@ -769,8 +771,8 @@ export default class Judge {
// 获取开始考试数据 // 获取开始考试数据
getJudgeBeginData = async () => { getJudgeBeginData = async () => {
const examinerInfo = AppStorage.get<ExaminerInfoType>('examinerInfo') const examinerInfo = AppStorage.get<ExaminerInfoType>('examinerInfo')
const code = examinerInfo.code // const code = examinerInfo.code
const examinerName = examinerInfo.name const examinerName = examinerInfo?.name||""
let currentParams: RouteParamsType = router.getParams() as RouteParamsType; let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
const sczb = currentParams.sczb; const sczb = currentParams.sczb;
@ -891,9 +893,9 @@ export default class Judge {
this.rmndg = 1 this.rmndg = 1
} }
this.judgeUI.currentXmdm = xmdm; this.judgeUI.currentXmdm = xmdm;
const xmmcStr = project.name; const xmmcStr = project.name||"";
const xmmcCode = project.projectCodeCenter; const xmmcCode = project.projectCodeCenter||"";
const xmmcSingleCode = project.projectCode; const xmmcSingleCode = project.projectCode||"";
const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode) const kmItem: KmItem = Reflect.get(this.kmItems, xmmcCode)
kmItem.status = 2; kmItem.status = 2;
this.xmmcStr = xmmcStr; this.xmmcStr = xmmcStr;
@ -904,13 +906,13 @@ export default class Judge {
this.xmxh = xmxh; this.xmxh = xmxh;
this.judgeUI.isProjectIn = true this.judgeUI.isProjectIn = true
Reflect.set(this.judgeUI.projectsObj, xmdm, project) Reflect.set(this.judgeUI.projectsObj, xmdm, project)
Reflect.set(this.kmItems, xmmcCode, kmItem) Reflect.set(this.kmItems, xmmcCode||0, kmItem)
break; break;
//项目结束 //项目结束
case 2: { case 2: {
const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm) const project: ProjectInfo = Reflect.get(judgeUI.projectsObj, xmdm)
const xmmcCode = project.projectCodeCenter; const xmmcCode = project.projectCodeCenter||"";
project.type = (xmjs.xmhg === 0 ? '4' : '3') project.type = (xmjs.xmhg === 0 ? '4' : '3')
//计算项目是否全部结束 //计算项目是否全部结束
@ -971,7 +973,7 @@ export default class Judge {
//考试结束 //考试结束
case 5: case 5:
this.ksjs = ksjs; this.ksjs = ksjs;
await fileLog.setExamJudgeData(JSON.stringify({ await fileLog?.setExamJudgeData(JSON.stringify({
method: 'examJudgeEndExam' method: 'examJudgeEndExam'
})) }))
break; break;
@ -982,7 +984,7 @@ export default class Judge {
const xmdm = xmqx.xmdm; 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 examSubject = this.judgeUI.examSubject
const xmmcCode = project.projectCodeCenter; const xmmcCode = project.projectCodeCenter||"";
// const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode); // const voiceCode = getKmProjectCancelVoice(examSubject, xmmcCode);
// avPlayer.playAudio([`voice/${voiceCode}.mp3`],true) // avPlayer.playAudio([`voice/${voiceCode}.mp3`],true)
project.type = '1' project.type = '1'
@ -1015,7 +1017,7 @@ export default class Judge {
const xmdm = precast.xmdm const xmdm = precast.xmdm
const xmxh = precast.xmxh 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 xmmcCode = project.projectCodeCenter||""
const projectCode = project.projectCode const projectCode = project.projectCode
// const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter; // const xmmcCode = judgeUI.projectsObj[xmdm].projectCodeCenter;
// const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode; // const xmmcSingleCode = judgeUI.projectsObj[xmdm].projectCode;

View File

@ -23,7 +23,7 @@ export function deepClone<T>(target: T): T {
const result: ESObject = Array.isArray(target) ? [] : {}; const result: ESObject = Array.isArray(target) ? [] : {};
const keys = Object.keys(target) as Array<keyof T>; //注解二 const keys = Object.keys(target) as Array<keyof T>; //注解二
keys.forEach(key => { keys.forEach(key => {
// Reflect.set(result, key, deepClone(Reflect.get(target, key))); Reflect.set(result, key, deepClone(Reflect.get(target, key)));
}); });
return result; return result;
} }

View File

@ -453,58 +453,60 @@ export const plcStrToJson = async (plc: string) => {
const plcArr = plc.split(',') const plcArr = plc.split(',')
const p = plcArr.map((val, key) => { const p = plcArr.map((val, key) => {
if (key !== 27 && key !== 92) { if (key !== 27 && key !== 92) {
return Number(val) return Number(val);
} else {
return 0; // 或者返回 undefined根据需求选择
} }
}); });
const time = await systemTime.getCurrentTime() const time = await systemTime.getCurrentTime()
const sensor: Sensor = { // const sensor: Sensor = {
//安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯 // //安全带 车门门开关 手刹 脚刹 副刹 离合器 喇叭 示宽灯 近光灯 远光灯
aqd: p[19], // aqd: p[19],
mkg: p[14], // mkg: p[14],
ssc: p[13], // ssc: p[13],
jsc: p[12], // jsc: p[12],
fsc: p[18], // fsc: p[18],
lhq: p[17], // lhq: p[17],
lb: p[4], // lb: p[4],
skd: p[9], // skd: p[9],
jgd: p[7], // jgd: p[7],
ygd: p[8], // ygd: p[8],
//左方向灯 右方向灯 双跳灯 雾灯 雨刮器 点火1 点火2 发动机转速 档位 车速 // //左方向灯 右方向灯 双跳灯 雾灯 雨刮器 点火1 点火2 发动机转速 档位 车速
zfxd: p[2], // zfxd: p[2],
yfxd: p[3], // yfxd: p[3],
shtd: p[20], // shtd: p[20],
wd: p[10], // wd: p[10],
ygq: p[11], // ygq: p[11],
dh1: p[5], // dh1: p[5],
dh2: p[6], // dh2: p[6],
fdjzs: p[25], // fdjzs: p[25],
dw: p[28], // dw: p[28],
cs: p[23], // cs: p[23],
// 方向盘 // // 方向盘
fxp: Number(plcArr[27].split('_')[0]), // fxp: Number(plcArr[27].split('_')[0]),
//累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量 // //累计脉冲 溜车脉冲 超声波左后 超声波右后 超声波右前 超声波左前 座椅 仪表盘 后视镜 倒车镜 光照 雨量
ljmc: p[24], // ljmc: p[24],
lcmc: 0, // lcmc: 0,
csbzh: p[32], // csbzh: p[32],
csbyh: p[30], // csbyh: p[30],
csbyq: p[31], // csbyq: p[31],
csbzq: p[29], // csbzq: p[29],
zy: 0, // zy: 0,
tbp: 0, // tbp: 0,
hsj: 0, // hsj: 0,
dcj: 0, // dcj: 0,
gx: 0, // gx: 0,
yl: 0, // yl: 0,
//TODO 数据待替换 油压 闪灯 信号灯 // //TODO 数据待替换 油压 闪灯 信号灯
yy: 0, // yy: 0,
sde: 0, // sde: 0,
xhd: '', // xhd: '',
rmndg: 0, // rmndg: 0,
wav: 0, // wav: 0,
mndg: '' // mndg: ''
} // }
const gps2: Gps = testRealExam.gps2 const gps2: Gps = testRealExam.gps2
const radar: Radar = testRealExam.radar const radar: Radar = testRealExam.radar
const vision: Vision = testRealExam.vision const vision: Vision = testRealExam.vision
@ -593,6 +595,8 @@ export const plcStrToWXJson = async (plc: string) => {
const p = plc.split(',').map((val, key) => { const p = plc.split(',').map((val, key) => {
if (key !== 27 && key !== 92) { if (key !== 27 && key !== 92) {
return Number(val) return Number(val)
}else{
return 0
} }
}); });
const timeStr = p[93] + '' + p[94]; const timeStr = p[93] + '' + p[94];

View File

@ -41,8 +41,8 @@ function plcStrToWXCodeArr(wuXiDataStr: string) {
export default class UsbService { export default class UsbService {
public isWXUSBDevice: Boolean public isWXUSBDevice: Boolean
private devicepipe: usb.USBDevicePipe private devicepipe?: usb.USBDevicePipe
private outEndpoint: usb.USBEndpoint private outEndpoint?: usb.USBEndpoint
sendUSB = async (wuXiDataStr: string) => { sendUSB = async (wuXiDataStr: string) => {
console.info(UsbTag, '正在发送数据') console.info(UsbTag, '正在发送数据')
console.info(UsbTag, '正在发送数据') console.info(UsbTag, '正在发送数据')
@ -110,7 +110,7 @@ export default class UsbService {
constructor() { constructor() {
//是否是无锡检测设备 //是否是无锡检测设备
this.isWXUSBDevice = false this.isWXUSBDevice = false
this.devicepipe // this.devicepipe
this.init() this.init()
} }
} }

View File

@ -1,7 +1,6 @@
{ {
"hvigorVersion": "3.2.4", "modelVersion": "5.0.0",
"dependencies": { "dependencies": {
"@ohos/hvigor-ohos-plugin": "3.2.4"
}, },
"execution": { "execution": {
// "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */

File diff suppressed because one or more lines are too long

View File

@ -1,19 +1,26 @@
{ {
"lockfileVersion": 2, "meta": {
"stableOrder": true
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": { "specifiers": {
"@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3", "@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3",
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19" "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19"
}, },
"packages": { "packages": {
"@ohos/hypium@1.0.19": { "@ohos/crypto-js@2.0.3": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har", "name": "@ohos/crypto-js",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", "version": "2.0.3",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har",
"registryType": "ohpm" "registryType": "ohpm"
}, },
"@ohos/crypto-js@2.0.3": { "@ohos/hypium@1.0.19": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har", "name": "@ohos/hypium",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==", "version": "1.0.19",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==",
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
"registryType": "ohpm" "registryType": "ohpm"
} }
} }

View File

@ -7,4 +7,4 @@
"devDependencies": { "devDependencies": {
"@ohos/hypium": "1.0.19" "@ohos/hypium": "1.0.19"
} }
} }