feat:科目二读取项目模型优化

This commit is contained in:
surenjun 2024-09-09 16:59:08 +08:00
parent 86e101e091
commit 6a131afd8a
6 changed files with 112 additions and 60 deletions

View File

@ -183,9 +183,11 @@ export async function getUDP2(context,errorFlag?) {
} }
if(val.body[0] == 11){ if(val.body[0] == 11){
console.info('surenjun','GlobalUdp收到beginExam事件')
globalThis.udpEvent.sendBeginExam() globalThis.udpEvent.sendBeginExam()
} }
if(val.body[0] == 12){ if(val.body[0] == 12){
console.info('surenjun','GlobalUdp收到endExam事件')
globalThis.udpEvent.sendEndExam() globalThis.udpEvent.sendEndExam()
} }

View File

@ -23,6 +23,7 @@ export default class JudgeEmitter{
} }
init = async ()=>{ init = async ()=>{
console.info('surenjun','开始注册udp事件')
emitter.on({eventId:EVENTID.beginExamEventId}, () => { emitter.on({eventId:EVENTID.beginExamEventId}, () => {
this?.beginExamCallBack() this?.beginExamCallBack()
}); });
@ -36,6 +37,7 @@ export default class JudgeEmitter{
//监听开始考试 //监听开始考试
public onBeginExam = async (callBack?:Function)=>{ public onBeginExam = async (callBack?:Function)=>{
console.info('surenjun','userInfo注册onBeginExam事件')
this.beginExamCallBack = callBack this.beginExamCallBack = callBack
} }
@ -50,14 +52,14 @@ export default class JudgeEmitter{
} }
//开始考试 //开始考试
public sendBeginExam = async(content)=>{ public sendBeginExam = async(content:string)=>{
emitter.emit({eventId:EVENTID.beginExamEventId}, { emitter.emit({eventId:EVENTID.beginExamEventId}, {
data:{ content } data:{ content }
}); });
} }
//结束考试 //结束考试
public sendEndExam = async(content)=>{ public sendEndExam = async(content:string)=>{
emitter.emit({eventId:EVENTID.endExamEventId}, { emitter.emit({eventId:EVENTID.endExamEventId}, {
data:{content} data:{content}
}); });

View File

@ -184,7 +184,7 @@ struct Index {
Column() { Column() {
Row() { Row() {
Column() { Column() {
Text('V 1.0') Text('V ' + globalThis.version)
.fontColor('#CCAE7A') .fontColor('#CCAE7A')
.fontSize(22 * globalThis.ratio) .fontSize(22 * globalThis.ratio)
.width('30%') .width('30%')

View File

@ -82,6 +82,7 @@ struct Index {
this.singlePlay = globalThis.singlePlay this.singlePlay = globalThis.singlePlay
} }
await this.initCDSBInfo() await this.initCDSBInfo()
await this.initItemInfo()
// 科目三新增读取表数据 // 科目三新增读取表数据
if (examSubject == 3) { if (examSubject == 3) {
@ -257,6 +258,7 @@ struct Index {
if (no1 == 3 && no3 == 1) { if (no1 == 3 && no3 == 1) {
if (txt1 === carName) { if (txt1 === carName) {
carNo = no2 carNo = no2
this.carlist = carNo
console.info('surenjun carNo => ',carNo) console.info('surenjun carNo => ',carNo)
} }
} }
@ -355,7 +357,28 @@ struct Index {
xmxh: key.split('~')[1], xmxh: key.split('~')[1],
} }
} }
})
}
// 获取itemInfo表信息
async initItemInfo(){
const infoParams = await getSyncData('MA_ITEMINFO');
const carlist = this.carlist;
const projectsObj = this.projectsObj
//@ts-ignore
infoParams.forEach((info)=>{
const key = decodeURI(info.itemsno);
const carlistArr = decodeURI(info.carlist).split(',') || []
const newKey = key.split('~').join('_')
//@ts-ignore
const xmdm = key.split('~')[0] * 1
if(projectsObj[xmdm] && (carlistArr.length == 0 || carlistArr.includes(carlist))){
this.itemInfoObj[newKey] = {
modelKey: newKey,
xmdm,
xmxh: key.split('~')[1],
}
}
}) })
} }
@ -1113,7 +1136,6 @@ struct Index {
//里程是否达标 && 必考项目是否全完成 //里程是否达标 && 必考项目是否全完成
return jl >= Number(examMileage) && isRequiredProjectsEnd return jl >= Number(examMileage) && isRequiredProjectsEnd
} }
return true return true
} }
@ -1160,7 +1182,7 @@ struct Index {
//405参数为2是如果在最左侧车道超车项目不能触发; //405参数为2是如果在最左侧车道超车项目不能触发;
if (projectCode == '10' && if (projectCode == '10' &&
judgeConfigObj['402'] == '2' && judgeConfigObj['405'] == '2' &&
(num === count) && (num === count) &&
num > 0 num > 0
) { ) {
@ -1231,6 +1253,7 @@ struct Index {
@State projectsCenterObj: ProjectObj = {} @State projectsCenterObj: ProjectObj = {}
@State markRuleListObj: MarkRule = {} @State markRuleListObj: MarkRule = {}
@State cdsbInfoObj: CDSBInfo = {} @State cdsbInfoObj: CDSBInfo = {}
@State itemInfoObj: CDSBInfo = {}
@State timer: number = 0 @State timer: number = 0
@State judgeConfig: { [k: string]: string }[] = [] @State judgeConfig: { [k: string]: string }[] = []
@State judgeConfigObj: { [k: string]: any } = defaultJudgeConfigObj @State judgeConfigObj: { [k: string]: any } = defaultJudgeConfigObj
@ -1288,4 +1311,5 @@ struct Index {
@State passingScore: number = 80 @State passingScore: number = 80
@State dwztErrorVisible: boolean = false; @State dwztErrorVisible: boolean = false;
@State popTimer:number =0; @State popTimer:number =0;
@State carlist:string= ''
} }

View File

@ -813,8 +813,77 @@ struct UserInfo {
return temp return temp
} }
//开始上车准备
prePareSCZB = async () => {
try {
await this.checkSignal()
this.isExamStart = true
this.currentUser.id = '0'
await upDateTableByArray('USER', [this.currentUser])
globalThis.statue = 4
this.isBoardPrePareSetPopupShow = true;
this.isFirstBoardPrePareSetPopupBtnShow = true;
this.stepFlag = false
this.stopDeviceById()
} catch (e) {
}
}
//开始考试准备
prePareExam = async() => {
if (this.ksksLimit) {
return
}
console.log('routerParamrouterParam')
try {
await this.checkSignal()
this.faceCompareSucess = 0
globalThis.statue = 2
if (!this.currentUser.xm) {
return
}
this.ksksLimit = true
if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo;
this.currentUser.id = '0'
await upDateTableByArray('USER', [this.currentUser])
router.pushUrl({
url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge',
params: {
sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm: this.sczbkf,
}
}, router.RouterMode.Single);
this.ksksLimit = false
this.stopDeviceById()
return
}
console.log('this.FaceOpenStatuethis.FaceOpenStatue',this.FaceOpenStatue)
if (this.FaceOpenStatue != '0') {
this.showFaceCompare = true
} else {
this.sfbdinterfaceFn()
}
} catch (e) {
console.info('Throw Error', JSON.stringify(e))
}
}
aboutToDisappear() { aboutToDisappear() {
this.outClick() this.outClick()
//监听远程开始考试
globalThis.udpEvent.onBeginExam(async ()=>{
console.info('surenjun','userInfo收到UdpEvent事件')
if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
await this.prePareSCZB()
}else{
await this.prePareExam()
}
})
} }
outClick() { outClick() {
@ -949,63 +1018,13 @@ struct UserInfo {
if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) { if (this.isBoardPrePareSetPopupOpen && !this.isFirstBoardPrePareSetPopupBtnShow) {
//上车准备 //上车准备
Image($r('app.media.sczb_btn')).commStyle().onClick(async () => { Image($r('app.media.sczb_btn')).commStyle().onClick(async () => {
try { await this.prePareSCZB()
await this.checkSignal()
this.isExamStart = true
this.currentUser.id = '0'
await upDateTableByArray('USER', [this.currentUser])
globalThis.statue = 4
this.isBoardPrePareSetPopupShow = true;
this.isFirstBoardPrePareSetPopupBtnShow = true;
this.stepFlag = false
this.stopDeviceById()
} catch (e) {
}
}) })
} else { } else {
Image($r('app.media.ksks_btn')) Image($r('app.media.ksks_btn'))
.commStyle() .commStyle()
.onClick(async () => { .onClick(async () => {
if (this.ksksLimit) { await this.prePareExam()
return
}
console.log('routerParamrouterParam')
try {
await this.checkSignal()
this.faceCompareSucess = 0
globalThis.statue = 2
if (!this.currentUser.xm) {
return
}
this.ksksLimit = true
if (globalThis.singlePlay) {
const {examSubject} = globalThis.carInfo;
this.currentUser.id = '0'
await upDateTableByArray('USER', [this.currentUser])
router.pushUrl({
url: examSubject == 3 ? 'pages/Roads' : 'pages/Judge',
params: {
sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm: this.sczbkf,
}
}, router.RouterMode.Single);
this.ksksLimit = false
this.stopDeviceById()
return
}
console.log('this.FaceOpenStatuethis.FaceOpenStatue',this.FaceOpenStatue)
if (this.FaceOpenStatue != '0') {
this.showFaceCompare = true
} else {
this.sfbdinterfaceFn()
}
} catch (e) {
console.info('Throw Error', JSON.stringify(e))
}
}) })
} }
} }

View File

@ -198,6 +198,9 @@ export default class Judge {
handDistance(); handDistance();
} }
}) })
globalThis.udpEvent.onBeginExam(async ()=>{
this.checkExamIsEnd(true);
})
//TODO 监听远程扣分 //TODO 监听远程扣分
} }
//实时计算gps经纬度距离 //实时计算gps经纬度距离
@ -227,13 +230,13 @@ export default class Judge {
const carInfo = globalThis.carInfo; const carInfo = globalThis.carInfo;
const { examSubject,plateNo,carId } = carInfo; const { examSubject,plateNo,carId } = carInfo;
const judgeUI = this.judgeUI const judgeUI = this.judgeUI
const {projectsObj,cdsbInfoObj,markRuleListObj,carType,carName,systemparmArr} = judgeUI const {projectsObj,itemInfoObj,markRuleListObj,carType,carName,systemparmArr} = judgeUI
const examType = examSubject == 2 ? 'km2' : 'km3' const examType = examSubject == 2 ? 'km2' : 'km3'
let allitems = []; let allitems = [];
if (examSubject == 2) { if (examSubject == 2) {
allitems = Reflect.ownKeys(cdsbInfoObj).map(cdsbKey => { allitems = Reflect.ownKeys(itemInfoObj).map(cdsbKey => {
const cdsb = cdsbInfoObj[cdsbKey]; const cdsb = itemInfoObj[cdsbKey];
const {xmdm,xmxh,modelKey} = cdsb const {xmdm,xmxh,modelKey} = cdsb
return { return {
xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`) xmdm, xmxh, model: getModelData(`${examType}/${modelKey}.txt`)
@ -254,6 +257,8 @@ export default class Judge {
systemparm: systemparmArr, systemparm: systemparmArr,
mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules, mark: Reflect.ownKeys(markRuleListObj).map(ruleKey => (markRuleListObj[ruleKey])) || testMarkRules,
sysset: judgeUI.judgeConfig, sysset: judgeUI.judgeConfig,
itemInfoObj,
carlist:judgeUI.carlist
}; };
let km3Config = {} let km3Config = {}