新评判重构

This commit is contained in:
lixiao 2025-10-10 16:16:36 +08:00
parent 9617c63ebb
commit 33459e85ec
8 changed files with 523 additions and 479 deletions

View File

@ -1,5 +1,5 @@
{ {
"lockfileVersion": 2, "lockfileVersion": 1,
"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": {} "packages": {}

View File

@ -104,6 +104,8 @@ export interface RouteParamsType {
kString?: string; kString?: string;
examItems?: string; examItems?: string;
fromIndex?: boolean; fromIndex?: boolean;
mode?: number
score?: number
} }
// 车辆信息 // 车辆信息

View File

@ -2,28 +2,29 @@ import {
JudgeConfigObjKmItems, JudgeConfigObjKmItems,
JudgeKSJS, JudgeKSJS,
JudgePerformInfo, JudgePerformInfo,
JudgeUI,
LANE, LANE,
MarkRule, MarkRule,
PLCType, PLCType,
ProcessDataEnumType, ProcessDataEnumType,
RecordHandleType, RecordHandleType,
WorkerBackMessage, WorkerBackMessage,
WorkerBackMessageType WorkerBackMessageType,
RouteParamsType
} from '../../model' } from '../../model'
import FileUtils from '../../utils/FileUtils' import FileUtils from '../../utils/FileUtils'
import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements' import VoiceAnnounce from '../judgeSDK/utils/voiceAnnouncements'
import common from '@ohos.app.ability.common' import common from '@ohos.app.ability.common'
import { LargeJudge, RouterParam, SmallJudge } from './JudgeStart' import { LargeJudge } from './LargeJudgeBusiness'
import { SmallJudge } from './SmallJudgeBusiness'
import { dConsole } from '../../utils/LogWorker' import { dConsole } from '../../utils/LogWorker'
import { JudgeTag } from '../../config' import { JudgeTag } from '../../config'
import { examJudgeRealExam } from './JudgeSDKUtils' import { examJudgeRealExam } from './JudgeSDKUtils'
import { JudgingFn, SetJudgeItem } from './JudgeIng' import { SetJudgeItem } from './JudgeIng'
import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker' import { DifferentialAndSignal } from '../../utils/business/DifferentialAndSignalWorker'
import { PlcStrToJson, PlcStrToWXJson } from './utils' import { PlcStrToJson, PlcStrToWXJson } from './utils'
import { JudgeEndFn } from './JudgeEnd'
import { BaseJudge } from './Typing' import { BaseJudge } from './Typing'
import router from '@ohos.router' import router from '@ohos.router'
import { JudgePage } from '../Judge';
export default class JudgeBusiness { export default class JudgeBusiness {
public mndgStr: string | undefined public mndgStr: string | undefined
@ -58,13 +59,13 @@ export default class JudgeBusiness {
public carztStr: string public carztStr: string
public ksjs?: JudgeKSJS public ksjs?: JudgeKSJS
public plcData?: PLCType public plcData?: PLCType
private judgeUI: JudgeUI private judgeUI: JudgePage
private tempData?: PLCType private tempData?: PLCType
// 是否发送udp // 是否发送udp
private isUdpEnd: boolean = false private isUdpEnd: boolean = false
judgeBusiness: BaseJudge private judgeBusiness: BaseJudge
constructor(judgeUI: JudgeUI) { constructor(judgeUI: JudgePage) {
this.judgeUI = judgeUI this.judgeUI = judgeUI
this.fileUtil = new FileUtils(judgeUI.context) this.fileUtil = new FileUtils(judgeUI.context)
this.avPlayer = new VoiceAnnounce(this.context); this.avPlayer = new VoiceAnnounce(this.context);
@ -106,7 +107,7 @@ export default class JudgeBusiness {
} }
public async JudgeInit() { public async JudgeInit() {
let currentParams: RouterParam = router.getParams() as RouterParam; let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
this.judgeBusiness.JudgeInit(currentParams.mode, this.judgeUI.carName) this.judgeBusiness.JudgeInit(currentParams.mode, this.judgeUI.carName)
} }
@ -129,12 +130,12 @@ export default class JudgeBusiness {
// 考试过程 callback优化 // 考试过程 callback优化
public async Judging(strData: string, callBack: Function) { public async Judging(strData: string, callBack: Function) {
JudgingFn(strData, callBack, this.judgeUI, this) this.judgeBusiness.Judging(strData, callBack, this.judgeUI, this)
} }
// 结束考试 // 结束考试
public JudgeEnd(isManual?: boolean) { public JudgeEnd(isManual?: boolean) {
JudgeEndFn(this.judgeUI, this, isManual) this.judgeBusiness.JudgeEnd(this.judgeUI, this, isManual)
} }
// 处理PLC数据 // 处理PLC数据

View File

@ -1,110 +0,0 @@
import { JudgeTag } from '../../config'
import { JudgeUI } from '../../model'
import { dConsole } from '../../utils/LogWorker'
import JudgeBusiness from './JudgeBusiness'
import { examJudgeEndExam } from './JudgeSDKUtils'
export const JudgeEndFn = async (judgeUI: JudgeUI, that: JudgeBusiness, isManual?: boolean) => {
const isAllProjectsEnd = judgeUI.isAllProjectsEnd
const examSubject = judgeUI.examSubject
const singlePlay = judgeUI.singlePlay
const totalScore = Number(judgeUI.totalScore)
const judgeConfigObj = judgeUI.judgeConfigObj
const examMileage = Number(judgeUI.examMileage)
const passingScore = Number(judgeUI.passingScore)
const jl = judgeUI.jl
if (that.isExamEnd) {
return
}
if (isManual) {
// 考试不合格
await examJudgeEndExam()
that.isExamEnd = true
that.isManual = true
} else {
const param302: number = Reflect.get(judgeConfigObj, '302')
const param342: number = Reflect.get(judgeConfigObj, '342')
const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(',');
//单机模式
if (singlePlay) {
dConsole.info(JudgeTag + ' 单机模式结束 => ', isAllProjectsEnd)
if (isAllProjectsEnd && jl >= examMileage) {
//成绩合格
if (totalScore >= passingScore && !that.isEndTip) {
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
(param302 != 6 && param302 != 7 && param302 != 8)) {
if (param512[7] != 0) {
clearTimeout(that.deductedPopShowTimer)
that.avPlayer?.playAudio(['voice/综合评判.mp3'])
judgeUI.isDeductedPopShow = true
judgeUI.defaultTabIndex = 1
that.isEndTip = true
return
}
} else {
await examJudgeEndExam()
that.isExamEnd = true
return
}
} else {
if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) {
await examJudgeEndExam()
that.isExamEnd = true
return
}
}
await examJudgeEndExam()
that.isExamEnd = true
}
} else {
//成绩不合格
if (totalScore < passingScore) {
//科目三不合格报靠边停车
if (examSubject == '3' && param302 == 1) {
that.avPlayer?.playAudio([`voice/考试结束.mp3`]);
return
}
await examJudgeEndExam()
that.isExamEnd = true
return
}
//成绩合格
if (isAllProjectsEnd && totalScore >= passingScore && !that.isEndTip) {
if (examSubject == '2') {
await examJudgeEndExam()
that.isExamEnd = true
return
}
//考试里程判断
if (examSubject == '3' && jl < examMileage) {
return
}
//考试合格自动退出
if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) {
await examJudgeEndExam()
that.isExamEnd = true
return
}
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
(param302 != 6 && param302 != 7 && param302 != 8)) {
if (param512[7] != 0) {
clearTimeout(that.deductedPopShowTimer)
judgeUI.isDeductedPopShow = false
that.avPlayer?.playAudio(['voice/综合评判.mp3'])
judgeUI.isDeductedPopShow = true
judgeUI.defaultTabIndex = 1
that.isEndTip = true
}
} else {
await examJudgeEndExam()
that.isExamEnd = true
}
}
}
}
}

View File

@ -1,4 +1,3 @@
//开始评判
import { JudgeConfig, JudgeTag } from '../../config'; import { JudgeConfig, JudgeTag } from '../../config';
import { import {
BaseInfoType, BaseInfoType,
@ -12,7 +11,6 @@ import {
JudgeInitObj, JudgeInitObj,
JudgeKFXM, JudgeKFXM,
JudgeKSXM, JudgeKSXM,
JudgeUI,
Km3JudgeInitConfig, Km3JudgeInitConfig,
MAPITEMPOINTITEM, MAPITEMPOINTITEM,
MAPPOINT, MAPPOINT,
@ -42,227 +40,11 @@ import { GetModelData } from './utils';
import { BaseJudge, GetSysSetResult } from './Typing'; import { BaseJudge, GetSysSetResult } from './Typing';
import { GetSyncData } from '../../utils/table/Operation'; import { GetSyncData } from '../../utils/table/Operation';
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
import { JudgePage } from '../Judge';
export interface RouterParam { export class LargeJudge implements BaseJudge {
mode: number 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) {
score: number
kString: string
wayno: number
}
export class SmallJudge implements BaseJudge {
public async JudgeInit(mode: number, carName: string): Promise<GetSysSetResult> {
const systemParams = await GetSyncData<SYSTEM_PARAM>('MA_SYSTEMPARM')
let currentParams: RouterParam = router.getParams() as RouterParam;
let totalScore: number
let wayno: number
let mockLight: boolean
let carlist: string
let passingScore: number
let examMileage: string
let projectsObj: Array<Project>
let projectsCenterObj: Array<String>
let ddxkKsxmArr: Array<string>
let singlePlay: boolean = AppStorage.get("singlePlay")
let systemparmArr: Array<SYSTEM_PARAM> = []
let projects: Array<Project> = []
let examSubject: string = ""
if (mode === 2) {
totalScore = Number(currentParams.score) || totalScore
}
if (singlePlay) {
wayno = currentParams.wayno || 1;
}
if (singlePlay) {
wayno = Number(currentParams.wayno) || 1;
}
//真实监管下发的项目
let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item);
let isInExam = kStringArr.length > 0;
let carNo: number, allItems: string[] = [];
systemParams.forEach((systemParam) => {
if (JudgeConfig.isTrajectoryOpen) {
systemParam.no1 = systemParam.NO1!;
systemParam.no2 = systemParam.NO2!;
systemParam.no3 = systemParam.NO3!;
systemParam.txt1 = systemParam.TXT1!;
systemParam.txt2 = systemParam.TXT2!;
systemParam.txt3 = systemParam.TXT3!;
}
const txt1 = decodeURI(systemParam.txt1 || "")
const txt2 = decodeURI(systemParam.txt2 || "")
const no1 = systemParam.no1;
const no2 = systemParam.no2;
const no3 = systemParam.no3;
//获取当前考车的no2
if (no1 == 3 && no3 == 1) {
if (txt1 === carName) {
carNo = no2
}
}
//获取及格分数线
if (no1 == 3 && no3 == 3 && carNo === no2) {
passingScore = Number(txt1) || 0;
}
//根据车型获取应行驶里程数
if (no1 == 3 && no3 == 15 && carNo === no2) {
examMileage = ((decodeURI(systemParam.txt1 || "")) || '').split('^')[0];
}
//获取当前考车的考试项目
if (carNo && no1 === 3 && no2 == carNo && no3 === 10) {
allItems = decodeURIComponent(systemParam.txt1 || "").split(',').filter(txt => txt !== '')
dConsole.info(JudgeTag, '考试项目', allItems)
}
if (
//科目二获取项目
(examSubject == "2" && allItems.length && no1 === 6 && allItems.includes(no2 + "" || ""))
||
//科目三获取项目
(examSubject == "3" && no1 === 6)
) {
const name = decodeURI(systemParam.txt1 || "")
//小车过滤掉 夜间模拟行驶
if (name === '夜间行驶') {
return
}
const currentProject: Project = {
name,
abbreviation: decodeURI(systemParam.txt3 || ""),
projectCode: no2 + '',
projectCodeCenter: txt2,
//是否是必考 加减档设置成非必考
isRequired: no2 === 14 ? false : allItems.includes(no2 + ''),
//是否考过了
isEnd: false,
//项目开始数据是否上传过
isUpload: false,
}
const no2Num = Number(no2)
//真实监管下发考试项目
if (isInExam && !(kStringArr.includes(txt2) || kStringArr.includes(no2 + ''))) {
dConsole.info(JudgeTag, 'surenjun =>', txt2)
dConsole.info(JudgeTag, 'surenjun => no2', no2)
currentProject.type = '3'
currentProject.isUpload = true
currentProject.isEnd = true
ddxkKsxmArr.push(txt2)
}
Reflect.set(projectsObj, no2Num, currentProject)
Reflect.set(projectsCenterObj, txt2, currentProject)
projects.push(currentProject);
}
systemparmArr.push({
NO1: Number(no1),
NO2: Number(no2),
NO3: Number(no3),
TXT1: decodeURIComponent(systemParam.txt1 || ""),
TXT2: decodeURIComponent(systemParam.txt2 || ""),
TXT3: decodeURIComponent(systemParam.txt3 || ""),
})
})
if (!projects.length) {
promptAction.showToast({
message: '读取数据库信息失败,请重新联网更新!',
duration: 8000
});
dConsole.log(JudgeTag, "router back3")
router.back();
}
return {
totalScore,
wayno,
mockLight,
carlist,
passingScore,
examMileage,
projectsObj,
projectsCenterObj,
ddxkKsxmArr,
singlePlay,
systemparmArr,
projects,
}
}
public async JudgeStart(callBack: Function, judgeUI: JudgeUI, that: JudgeBusiness) {
const name = judgeUI.name
const kssycs = judgeUI.kssycs
const manualMarkRules = judgeUI.manualMarkRules
// 处理单机模式
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool');
const trajectoryPath = JudgeConfig.trajectoryPath;
let strArr: string[] = [];
if (isTrajectoryOpen) {
const folderPath = await that.fileUtil.initFolder(trajectoryPath);
const str: string = await that.fileUtil.readFile(folderPath)
strArr = str.split('\n')
}
//日志回调
dConsole.info(JudgeTag, '1.进入评判入口')
await examJudgeSetLogCallback(6, async (level: number, info: string, len: number) => {
dConsole.log(JudgeTag, '评判日志:' + info)
dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info)
})
dConsole.info(JudgeTag, '2.注册日志回调完成')
let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.GetJudgeInitData(judgeUI.context, judgeUI.markRuleListObj, judgeUI.carType, judgeUI.carName, judgeUI.systemparmArr, judgeUI.carinfoArr, judgeUI.examSubject, judgeUI.itemInfoObj, judgeUI.judgeConfig, judgeUI.carlist, judgeUI.mapPointArr, judgeUI.mapPointItemArr);
//相关评判初始化只做一次
if (!isJudgeInitBool) {
dConsole.log(JudgeTag, "评判初始化参数", initInfo)
await examJudgeInit(initInfo);
AppStorage.setOrCreate('isJudgeInitBool', true)
dConsole.info(JudgeTag, '4.评判初始化完成')
}
AppStorage.setOrCreate('isJudge', true)
// 2.评判过程回调
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
// 评判回调日志
dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData, strData)
dConsole.info(JudgeTag, '评判回调数据', strData)
await that.Judging(strData, callBack)
})
await examJudgeSetPerformCallback(async (info: string) => {
dConsole.info('评判实时数据', info)
that.performInfo = JSON.parse(info)
const jl = Math.floor((that.performInfo.qjjl + that.performInfo.dcjl) / 100);
if (jl > Number(judgeUI.examMileage)) {
that.JudgeEnd()
}
judgeUI.jl = jl
judgeUI.laneSignal = that.performInfo.lane
})
let beginExamInfo: JudgeBeginObj | undefined = undefined
// 3.开始考试
if (isTrajectoryOpen) {
beginExamInfo = JSON.parse(strArr[1])
beginExamInfo && (beginExamInfo.replay = 1)
} else {
beginExamInfo = await this.GetJudgeBeginData(judgeUI.projects, judgeUI.carType, judgeUI.kssycs, judgeUI.isDdxk, judgeUI.ddxkTime, judgeUI.projectsCenterObj, judgeUI.ddxkKsxmArr, judgeUI.ddxkKfArr, judgeUI.passingScore, judgeUI.wayno, judgeUI.name, judgeUI.lsh, judgeUI.idCard, that.isExam)
}
if (beginExamInfo) {
await examJudgeBeginExam(beginExamInfo);
}
dConsole.info(JudgeTag, '6.开始考试注册完成')
that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
if (!judgeUI.singlePlay) {
that.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, that.context)
}
judgeUI.draw = true
// 处理单机泡轨迹模式
if (isTrajectoryOpen) {
that.SingleMachineTrajectory(strArr)
return
}
};
public async GetJudgeBeginData(projects: ProjectInfo[], 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 examinerInfo = AppStorage.get<ExaminerInfoType>('examinerInfo')
const examinerName = examinerInfo?.name || "" const examinerName = examinerInfo?.name || ""
let currentParams: RouteParamsType = router.getParams() as RouteParamsType; let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
@ -322,7 +104,7 @@ export class SmallJudge implements BaseJudge {
return beginInfo return beginInfo
}; };
public 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[]) { 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 carInfo = AppStorage.get<CarInfoType>('carInfo');
const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3' const examType = carInfo?.examSubject == '2' ? 'km2' : 'km3'
@ -384,13 +166,10 @@ export class SmallJudge implements BaseJudge {
dConsole.info(JudgeTag, '3.获取评判初始化数据完成') dConsole.info(JudgeTag, '3.获取评判初始化数据完成')
return initInfo return initInfo
}; };
}
export class LargeJudge implements BaseJudge {
public async JudgeInit(mode: number, carName: string): Promise<GetSysSetResult> { public async JudgeInit(mode: number, carName: string): Promise<GetSysSetResult> {
const systemParams = await GetSyncData<SYSTEM_PARAM>('MA_SYSTEMPARM') const systemParams = await GetSyncData<SYSTEM_PARAM>('MA_SYSTEMPARM')
let currentParams: RouterParam = router.getParams() as RouterParam; let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
let totalScore: number let totalScore: number
let wayno: number let wayno: number
let mockLight: boolean let mockLight: boolean
@ -407,7 +186,7 @@ export class LargeJudge implements BaseJudge {
totalScore = Number(currentParams.score) || totalScore totalScore = Number(currentParams.score) || totalScore
} }
if (singlePlay) { if (singlePlay) {
wayno = currentParams.wayno || 1; wayno = Number(currentParams.wayno) || 1;
} }
//真实监管下发的项目 //真实监管下发的项目
let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item); let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item);
@ -563,7 +342,7 @@ export class LargeJudge implements BaseJudge {
} }
} }
public async JudgeStart(callBack: Function, judgeUI: JudgeUI, that: JudgeBusiness) { public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
const name = judgeUI.name const name = judgeUI.name
const kssycs = judgeUI.kssycs const kssycs = judgeUI.kssycs
// 处理远程扣分使用 // 处理远程扣分使用
@ -637,126 +416,11 @@ export class LargeJudge implements BaseJudge {
} }
}; };
public async GetJudgeBeginData(projects: ProjectInfo[], 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) { public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
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 systemTime.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: false,
mfxx: false,
mfxxn: false
}
dConsole.info(JudgeTag, '5.获取开始考试数据完成')
return beginInfo
};
public 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[] = []; public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) {
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
}; };
} }

View File

@ -0,0 +1,486 @@
import { JudgeConfig, JudgeTag } from '../../config';
import {
BaseInfoType,
CAR_INFO,
CarInfoType,
CDSBInfo,
ExaminerInfoType,
ItemInfo,
ItemInfos,
JudgeBeginObj,
JudgeInitObj,
JudgeKFXM,
JudgeKSXM,
Km3JudgeInitConfig,
MAPITEMPOINTITEM,
MAPPOINT,
MarkRule,
ProcessDataEnumType,
ProjectInfo,
RouteParamsType,
SyssetConfig,
SYSTEM_PARAM,
Project
} from '../../model';
import common from '@ohos.app.ability.common';
import { dConsole } from '../../utils/LogWorker';
import {
examJudgeBeginExam,
examJudgeEndExam,
examJudgeInit,
examJudgeSetLogCallback,
examJudgeSetPerformCallback,
examJudgeSetRealExamCallback,
examJudgeVersion
} from './JudgeSDKUtils';
import JudgeBusiness from './JudgeBusiness';
import { saveStartRecordVideo } from '../../utils/Video';
import router from '@ohos.router';
import systemTime from '@ohos.systemTime';
import { GetModelData } from './utils';
import { BaseJudge, GetSysSetResult } from './Typing';
import { GetSyncData } from '../../utils/table/Operation';
import promptAction from '@ohos.promptAction';
import { JudgePage } from '../Judge';
export class SmallJudge implements BaseJudge {
public 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 systemTime.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: false,
mfxx: false,
mfxxn: false
}
dConsole.info(JudgeTag, '5.获取开始考试数据完成')
return beginInfo
};
public 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(mode: number, carName: string): Promise<GetSysSetResult> {
const systemParams = await GetSyncData<SYSTEM_PARAM>('MA_SYSTEMPARM')
let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
let totalScore: number
let wayno: number
let mockLight: boolean
let carlist: string
let passingScore: number
let examMileage: string
let projectsObj: Array<Project>
let projectsCenterObj: Array<String>
let ddxkKsxmArr: Array<string>
let singlePlay: boolean = AppStorage.get("singlePlay")
let systemparmArr: Array<SYSTEM_PARAM> = []
let projects: Array<Project> = []
let examSubject: string = ""
if (mode === 2) {
totalScore = Number(currentParams.score) || totalScore
}
if (singlePlay) {
wayno = Number(currentParams.wayno) || 1;
}
//真实监管下发的项目
let kStringArr: string[] = (currentParams.kString?.split(',') || []).filter(item => item);
let isInExam = kStringArr.length > 0;
let carNo: number, allItems: string[] = [];
systemParams.forEach((systemParam) => {
if (JudgeConfig.isTrajectoryOpen) {
systemParam.no1 = systemParam.NO1!;
systemParam.no2 = systemParam.NO2!;
systemParam.no3 = systemParam.NO3!;
systemParam.txt1 = systemParam.TXT1!;
systemParam.txt2 = systemParam.TXT2!;
systemParam.txt3 = systemParam.TXT3!;
}
const txt1 = decodeURI(systemParam.txt1 || "")
const txt2 = decodeURI(systemParam.txt2 || "")
const no1 = systemParam.no1;
const no2 = systemParam.no2;
const no3 = systemParam.no3;
//获取当前考车的no2
if (no1 == 3 && no3 == 1) {
if (txt1 === carName) {
carNo = no2
}
}
//获取及格分数线
if (no1 == 3 && no3 == 3 && carNo === no2) {
passingScore = Number(txt1) || 0;
}
//根据车型获取应行驶里程数
if (no1 == 3 && no3 == 15 && carNo === no2) {
examMileage = ((decodeURI(systemParam.txt1 || "")) || '').split('^')[0];
}
//获取当前考车的考试项目
if (carNo && no1 === 3 && no2 == carNo && no3 === 10) {
allItems = decodeURIComponent(systemParam.txt1 || "").split(',').filter(txt => txt !== '')
dConsole.info(JudgeTag, '考试项目', allItems)
}
if (
//科目二获取项目
(examSubject == "2" && allItems.length && no1 === 6 && allItems.includes(no2 + "" || ""))
||
//科目三获取项目
(examSubject == "3" && no1 === 6)
) {
const name = decodeURI(systemParam.txt1 || "")
//小车过滤掉 夜间模拟行驶
if (name === '夜间行驶') {
return
}
const currentProject: Project = {
name,
abbreviation: decodeURI(systemParam.txt3 || ""),
projectCode: no2 + '',
projectCodeCenter: txt2,
//是否是必考 加减档设置成非必考
isRequired: no2 === 14 ? false : allItems.includes(no2 + ''),
//是否考过了
isEnd: false,
//项目开始数据是否上传过
isUpload: false,
}
const no2Num = Number(no2)
//真实监管下发考试项目
if (isInExam && !(kStringArr.includes(txt2) || kStringArr.includes(no2 + ''))) {
dConsole.info(JudgeTag, 'surenjun =>', txt2)
dConsole.info(JudgeTag, 'surenjun => no2', no2)
currentProject.type = '3'
currentProject.isUpload = true
currentProject.isEnd = true
ddxkKsxmArr.push(txt2)
}
Reflect.set(projectsObj, no2Num, currentProject)
Reflect.set(projectsCenterObj, txt2, currentProject)
projects.push(currentProject);
}
systemparmArr.push({
NO1: Number(no1),
NO2: Number(no2),
NO3: Number(no3),
TXT1: decodeURIComponent(systemParam.txt1 || ""),
TXT2: decodeURIComponent(systemParam.txt2 || ""),
TXT3: decodeURIComponent(systemParam.txt3 || ""),
})
})
if (!projects.length) {
promptAction.showToast({
message: '读取数据库信息失败,请重新联网更新!',
duration: 8000
});
dConsole.log(JudgeTag, "router back3")
router.back();
}
return {
totalScore,
wayno,
mockLight,
carlist,
passingScore,
examMileage,
projectsObj,
projectsCenterObj,
ddxkKsxmArr,
singlePlay,
systemparmArr,
projects,
}
}
public async JudgeStart(callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
const name = judgeUI.name
const kssycs = judgeUI.kssycs
const manualMarkRules = judgeUI.manualMarkRules
// 处理单机模式
const isTrajectoryOpen = JudgeConfig.isTrajectoryOpen;
const isJudgeInitBool = AppStorage.get<boolean>('isJudgeInitBool');
const trajectoryPath = JudgeConfig.trajectoryPath;
let strArr: string[] = [];
if (isTrajectoryOpen) {
const folderPath = await that.fileUtil.initFolder(trajectoryPath);
const str: string = await that.fileUtil.readFile(folderPath)
strArr = str.split('\n')
}
//日志回调
dConsole.info(JudgeTag, '1.进入评判入口')
await examJudgeSetLogCallback(6, async (level: number, info: string, len: number) => {
dConsole.log(JudgeTag, '评判日志:' + info)
dConsole.writeProcessData(ProcessDataEnumType.JudgeLogData, info)
})
dConsole.info(JudgeTag, '2.注册日志回调完成')
let initInfo: JudgeInitObj = isTrajectoryOpen ? JSON.parse(strArr[0]) : await this.GetJudgeInitData(judgeUI.context, judgeUI.markRuleListObj, judgeUI.carType, judgeUI.carName, judgeUI.systemparmArr, judgeUI.carinfoArr, judgeUI.examSubject, judgeUI.itemInfoObj, judgeUI.judgeConfig, judgeUI.carlist, judgeUI.mapPointArr, judgeUI.mapPointItemArr);
//相关评判初始化只做一次
if (!isJudgeInitBool) {
dConsole.log(JudgeTag, "评判初始化参数", initInfo)
await examJudgeInit(initInfo);
AppStorage.setOrCreate('isJudgeInitBool', true)
dConsole.info(JudgeTag, '4.评判初始化完成')
}
AppStorage.setOrCreate('isJudge', true)
// 2.评判过程回调
await examJudgeSetRealExamCallback(async (strData: string, len: number) => {
// 评判回调日志
dConsole.writeProcessData(ProcessDataEnumType.JudgeProgressCallbackData, strData)
dConsole.info(JudgeTag, '评判回调数据', strData)
await that.Judging(strData, callBack)
})
await examJudgeSetPerformCallback(async (info: string) => {
dConsole.info('评判实时数据', info)
that.performInfo = JSON.parse(info)
const jl = Math.floor((that.performInfo.qjjl + that.performInfo.dcjl) / 100);
if (jl > Number(judgeUI.examMileage)) {
that.JudgeEnd()
}
judgeUI.jl = jl
judgeUI.laneSignal = that.performInfo.lane
})
let beginExamInfo: JudgeBeginObj | undefined = undefined
// 3.开始考试
if (isTrajectoryOpen) {
beginExamInfo = JSON.parse(strArr[1])
beginExamInfo && (beginExamInfo.replay = 1)
} else {
beginExamInfo = await this.GetJudgeBeginData(judgeUI.projects, judgeUI.carType, judgeUI.kssycs, judgeUI.isDdxk, judgeUI.ddxkTime, judgeUI.projectsCenterObj, judgeUI.ddxkKsxmArr, judgeUI.ddxkKfArr, judgeUI.passingScore, judgeUI.wayno, judgeUI.name, judgeUI.lsh, judgeUI.idCard, that.isExam)
}
if (beginExamInfo) {
await examJudgeBeginExam(beginExamInfo);
}
dConsole.info(JudgeTag, '6.开始考试注册完成')
that.avPlayer?.playAudio([judgeUI.singlePlay ? 'voice/ksks.wav' : 'voice/监管成功.mp3'])
if (!judgeUI.singlePlay) {
that.videoData = await saveStartRecordVideo(`${name}_${kssycs}`, that.context)
}
judgeUI.draw = true
// 处理单机泡轨迹模式
if (isTrajectoryOpen) {
that.SingleMachineTrajectory(strArr)
return
}
};
public async Judging(strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) {
}
public async JudgeEnd(judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) {
const isAllProjectsEnd = judgeUI.isAllProjectsEnd
const examSubject = judgeUI.examSubject
const singlePlay = judgeUI.singlePlay
const totalScore = Number(judgeUI.totalScore)
const judgeConfigObj = judgeUI.judgeConfigObj
const examMileage = Number(judgeUI.examMileage)
const passingScore = Number(judgeUI.passingScore)
const jl = judgeUI.jl
if (that.isExamEnd) {
return
}
if (isManual) {
// 考试不合格
await examJudgeEndExam()
that.isExamEnd = true
that.isManual = true
} else {
const param302: number = Reflect.get(judgeConfigObj, '302')
const param342: number = Reflect.get(judgeConfigObj, '342')
const param512: number[] = (Reflect.get(judgeConfigObj, '512') || '').split(',');
//单机模式
if (singlePlay) {
dConsole.info(JudgeTag + ' 单机模式结束 => ', isAllProjectsEnd)
if (isAllProjectsEnd && jl >= examMileage) {
//成绩合格
if (totalScore >= passingScore && !that.isEndTip) {
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
(param302 != 6 && param302 != 7 && param302 != 8)) {
if (param512[7] != 0) {
clearTimeout(that.deductedPopShowTimer)
that.avPlayer?.playAudio(['voice/综合评判.mp3'])
judgeUI.isDeductedPopShow = true
judgeUI.defaultTabIndex = 1
that.isEndTip = true
return
}
} else {
await examJudgeEndExam()
that.isExamEnd = true
return
}
} else {
if (examSubject == '3' && (param302 == 4 || param302 == 5 || param302 == 7 || param302 == 8)) {
await examJudgeEndExam()
that.isExamEnd = true
return
}
}
await examJudgeEndExam()
that.isExamEnd = true
}
} else {
//成绩不合格
if (totalScore < passingScore) {
//科目三不合格报靠边停车
if (examSubject == '3' && param302 == 1) {
that.avPlayer?.playAudio([`voice/考试结束.mp3`]);
return
}
await examJudgeEndExam()
that.isExamEnd = true
return
}
//成绩合格
if (isAllProjectsEnd && totalScore >= passingScore && !that.isEndTip) {
if (examSubject == '2') {
await examJudgeEndExam()
that.isExamEnd = true
return
}
//考试里程判断
if (examSubject == '3' && jl < examMileage) {
return
}
//考试合格自动退出
if (examSubject == '3' && (param302 == 4 || param302 == 7) || param302 == 8) {
await examJudgeEndExam()
that.isExamEnd = true
return
}
if (examSubject == '3' && (param342 == 0 || param342 == 2) &&
(param302 != 6 && param302 != 7 && param302 != 8)) {
if (param512[7] != 0) {
clearTimeout(that.deductedPopShowTimer)
judgeUI.isDeductedPopShow = false
that.avPlayer?.playAudio(['voice/综合评判.mp3'])
judgeUI.isDeductedPopShow = true
judgeUI.defaultTabIndex = 1
that.isEndTip = true
}
} else {
await examJudgeEndExam()
that.isExamEnd = true
}
}
}
}
};
}

View File

@ -1,8 +1,9 @@
import { JudgeUI, Project, SYSTEM_PARAM, } from '../../model' import { Project, SYSTEM_PARAM, } from '../../model'
import JudgeBusiness from './JudgeBusiness' import JudgeBusiness from './JudgeBusiness'
import { JudgePage } from "../Judge"
export interface GetSysSetResult { export interface GetSysSetResult {
totalScore: number totalScore: number
wayno: number wayno: number
mockLight: boolean mockLight: boolean
@ -19,5 +20,7 @@ export interface GetSysSetResult {
export interface BaseJudge { export interface BaseJudge {
JudgeInit: (mode: number, carName: string) => Promise<GetSysSetResult> JudgeInit: (mode: number, carName: string) => Promise<GetSysSetResult>
JudgeStart: (callBack: Function, judgeUI: JudgeUI, that: JudgeBusiness) => void JudgeStart: (callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) => void
Judging: (strData: string, callBack: Function, judgeUI: JudgePage, that: JudgeBusiness) => void
JudgeEnd: (judgeUI: JudgePage, that: JudgeBusiness, isManual?: boolean) => void
} }

View File

@ -1,20 +1,18 @@
{ {
"lockfileVersion": 2, "lockfileVersion": 1,
"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": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==",
"registryType": "ohpm"
},
"@ohos/crypto-js@2.0.3": { "@ohos/crypto-js@2.0.3": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har", "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/crypto-js/-/crypto-js-2.0.3.har",
"integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ==", "integrity": "sha512-LuHaR1kD5PxnOXnuR1fWvPwGtbed9Q/QGzk6JOh8y5Wdzvi8brPesODZiaWf9scOVRHsbTPOtZw91vWB35p1vQ=="
"registryType": "ohpm" },
"@ohos/hypium@1.0.19": {
"resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.19.har",
"integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ=="
} }
} }
} }