fix: 优化一些错误

This commit is contained in:
wangzhongjie 2025-03-31 10:36:57 +08:00
parent d836b58f9a
commit 4319805f45
4 changed files with 618 additions and 582 deletions

View File

@ -10,52 +10,39 @@ import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon';
import { uploadExamMileage } from '../api/judge';
import DwztErrorPopup from './compontents/judge/DwztErrorPopup';
import MsgPopup from './compontents/judge/MsgPopup';
import {
CARINFO,
CDSBInfo,
LANE,
MAPITEMPOINTITEM,
MAPPOINT,
MarkRule,
Project,
ProjectObj,
SYSTEMPARMARR
CARINFO,
CDSBInfo,
LANE,
MAPITEMPOINTITEM,
MAPPOINT,
MarkRule,
Project, SYSTEMPARMARR
} from './judgeSDK/api/judgeSDK.d';
import { judgeConfig } from './judgeSDK/utils/judgeConfig';
import SignDisplayCom from './compontents/signDisplayCom';
import {
CarInfoType,
CommonType,
ES_CARINFOType,
KfdmType,
MA_CDSBINFOType,
MA_ITEMINFOType,
MA_MAP_POINT_ITEMType,
MA_MAP_POINTType,
MA_MARKRULEType,
MA_SYSTEMPARMType,
MASYSSETTableType,
RouteParamsType,
User,
SYSSET,
SyssetConfig,
ProjectInfo,
ProjectInfos,
ProjectCenterInfos,
JudgeInitObj,
JudgeBeginObj,
UploadExamMileage,
AmplifyItem,
ProjectRoads,
JudgeCallBacData,
JudgeUI,
CDSBInfos,
ItemInfos,
MarkRules,
DefaultJudgeConfigObj
AmplifyItem,
CarInfoType,
CDSBInfos, DefaultJudgeConfigObj,
ES_CARINFOType,
ItemInfos,
JudgeBeginObj,
JudgeCallBacData,
JudgeInitObj,
JudgeUI, MA_CDSBINFOType,
MA_ITEMINFOType,
MA_MAP_POINT_ITEMType,
MA_MAP_POINTType, MA_SYSTEMPARMType,
MarkRules,
MASYSSETTableType, ProjectInfo,
ProjectInfos,
ProjectRoads,
RouteParamsType,
SYSSET,
SyssetConfig, User
} from '../model';
import { GetSyncData } from '../utils/table/Operation';
import dayTs from '../utils/Date';
@ -168,23 +155,23 @@ struct Index {
@State carInfo: CarInfoType = {}
@State isErrorMsgEnd: boolean = false
@State disConnectErrorOpen: boolean = false
public context = getContext(this) as common.UIAbilityContext;
public context = getContext(this) as common.UIAbilityContext;
async aboutToDisappear() {
clearInterval(this.mileageTimer)
}
async aboutToAppear() {
const time = GetCurrentTime()
const time = GetCurrentTime()
this.carInfo = AppStorage.get<CarInfoType>('carInfo')
this.singlePlay = AppStorage.get<boolean>('singlePlay')
this.startTime = time.split(' ')[1]
this.startFullTime = GetCurrentTime(1);
this.startFullTime = GetCurrentTime(1);
// this.startHourTime = await getCurrentHourTime()
this.startTime = dayTs().format("HHmmssSSS")
this.startExamTime = time
setInterval(async () => {
this.time = GetCurrentTime();
this.time = GetCurrentTime();
this.examTime += 1;
}, 1000);
//初始化数据库表
@ -251,7 +238,6 @@ struct Index {
async initStudent() {
const students = await GetSyncData<User>('USER')
const stuInfo = students[0];
// const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl, xldm } = stuInfo;
this.name = stuInfo.xm || '测试考生';
this.idCard = stuInfo.sfzmhm || '01234567891010';
this.lsh = this.singlePlay ? '0000000000000' : stuInfo.lsh;
@ -269,7 +255,7 @@ struct Index {
const markRuleParams = markRules || await GetSyncData<MarkRule>('MA_MARKRULE')
markRuleParams.forEach(mark => {
const tempObj:MarkRule = {
const tempObj: MarkRule = {
itemno: mark.itemno * 1,
markcatalog: mark.markcatalog,
markshow: decodeURI(mark.markshow),
@ -299,9 +285,9 @@ struct Index {
console.info('surenjun serialNumberArr' + JSON.stringify(serialNumberArr))
this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '';
// const { isTrajectoryOpen } = judgeConfig
const syssetJudgeConfigArr:SyssetConfig[] = []
const syssetJudgeConfigArr: SyssetConfig[] = []
syssetParams.forEach((sys:SYSSET) => {
syssetParams.forEach((sys: SYSSET) => {
if (judgeConfig.isTrajectoryOpen) {
sys.v_no = String(sys.key);
sys.v_name = sys.name;
@ -309,7 +295,7 @@ struct Index {
}
// const { v_no, v_value } = sys;
const v_no_num = Number(sys.v_no)
const v_no_num = Number(sys.v_no)
const value = decodeURIComponent(sys.v_value)
if (v_no_num >= 10 && v_no_num <= 900) {
const name =
@ -342,8 +328,8 @@ struct Index {
currentParams.kfdm.forEach(kf => {
// const { xmdm, kfdm } = kf
const currentKf: MarkRule = Reflect.get(this.markRuleListObj,`${kf.xmdm}_${kf.kfdm}`)
const currentProject:ProjectInfo = Reflect.get(this.projectsObj,kf.xmdm)
const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${kf.xmdm}_${kf.kfdm}`)
const currentProject: ProjectInfo = Reflect.get(this.projectsObj, kf.xmdm)
// 过滤考前绕车一周上车准备的扣分
if (currentParams.sczb == "1" && kf.xmdm == 1) {
@ -353,7 +339,7 @@ struct Index {
this.kfArr.push({
//扣分项目名称
xmmcStr: currentProject.name,
xmdm:kf.xmdm,
xmdm: kf.xmdm,
desc: currentKf.markshow,
score: currentKf.markreal,
markcatalog: currentKf.markcatalog,
@ -362,9 +348,9 @@ struct Index {
})
this.totalScore += currentKf.markreal * 1;
})
const project_1 = Reflect.get(this.projectsObj,1)
project_1.type = kfdm.length ? '4' : '3';
Reflect.set(this.projectsObj,1,project_1)
const project_1 = Reflect.get(this.projectsObj, 1)
project_1.type = kfdm.length ? '4' : '3';
Reflect.set(this.projectsObj, 1, project_1)
}
Reflect.set(this.judgeConfigObj, sys.v_no, value)
@ -388,7 +374,7 @@ struct Index {
console.info('surenjun kStringArr', JSON.stringify(kStringArr))
let isInExam = kStringArr.length > 0;
// const { isTrajectoryOpen } = judgeConfig
let carNo = '', allItems:string[] = [];
let carNo = '', allItems: string[] = [];
systemParms.forEach((systemParm) => {
if (judgeConfig.isTrajectoryOpen) {
systemParm.no1 = systemParm.NO1 + '';
@ -439,7 +425,7 @@ struct Index {
if (sCarTypes.includes(this.carType) && name === '夜间行驶') {
return
}
const currentProject:ProjectInfo = {
const currentProject: ProjectInfo = {
name,
abbreviation: decodeURI(systemParm.txt3),
projectCode: no2,
@ -495,10 +481,10 @@ struct Index {
cdsbParams.forEach((cdsb) => {
const key = decodeURI(cdsb.itemsno)
const newKey = key.split('~').join('_')
const xmdm = Number( key.split('~')[0] )
const currentProject:ProjectInfo = Reflect.get(projectsObj, xmdm)
const xmdm = Number(key.split('~')[0])
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
if (currentProject) {
const cdsbInfo:CDSBInfo = {
const cdsbInfo: CDSBInfo = {
kdid: cdsb.kdid,
sbbh: cdsb.sbbh,
sbbm: cdsb.sbbm,
@ -522,9 +508,9 @@ struct Index {
const carlistArr = info.carlist === '' ? [] : (decodeURI(info.carlist).split(',') || []);
const newKey = key.split('~').join('_')
const xmdm = Number(key.split('~')[0])
const currentProject:ProjectInfo = Reflect.get(projectsObj,xmdm)
const currentProject: ProjectInfo = Reflect.get(projectsObj, xmdm)
if (currentProject && (carlistArr.length == 0 || carlistArr.includes(carlist))) {
Reflect.set(this.itemInfoObj,newKey, {
Reflect.set(this.itemInfoObj, newKey, {
modelKey: newKey,
xmdm,
xmxh: key.split('~')[1],
@ -535,10 +521,10 @@ struct Index {
// 评判相关初始化
async initJudge() {
const JUDGEUI:JudgeUI = this;
const JUDGEUI: JudgeUI = this;
const judge = new Judge(JUDGEUI);
// await judge.init<typeof Index>()
await judge.onJudgeFn(async (judgeData:JudgeCallBacData) => {
await judge.onJudgeFn(async (judgeData: JudgeCallBacData) => {
// const { xmmcStr, carztStr, kfArr } = judgeData;
this.xmmcStr = judgeData.xmmcStr;
this.carztStr = judgeData.carztStr;
@ -551,7 +537,7 @@ struct Index {
async goDdxkItems() {
const judgeConfigObj = this.judgeConfigObj
const config_432:string = Reflect.get(judgeConfigObj,'432')
const config_432: string = Reflect.get(judgeConfigObj, '432')
//科目二强制开始断点续考
if (config_432 != '0' || this.examSubject == "2") {
//断点续考判断
@ -569,9 +555,9 @@ struct Index {
if (ddxkKsxmArr?.length) {
//断点续考
ddxkKsxmArr.forEach(xmdm => {
const currentProjectCenter:Project = Reflect.get(this.projectsCenterObj, xmdm)
const currentProjectCenter: Project = Reflect.get(this.projectsCenterObj, xmdm)
const projectCode = currentProjectCenter.projectCode
const currentProject:Project = Reflect.get(this.projectsObj,projectCode)
const currentProject: Project = Reflect.get(this.projectsObj, projectCode)
if (currentProject) {
currentProject.type = '3'
currentProject.isUpload = true
@ -586,8 +572,8 @@ struct Index {
ddxkKfArr.forEach((kf) => {
const xmdm = kf.split(',')[0]
const kfdm = kf.split(',')[1]
const currentKf:MarkRule = Reflect.get(this.markRuleListObj, `${xmdm}_${kfdm}`)
const currentProject:ProjectInfo = Reflect.get(this.projectsObj,xmdm) || { name: '通用评判' }
const currentKf: MarkRule = Reflect.get(this.markRuleListObj, `${xmdm}_${kfdm}`)
const currentProject: ProjectInfo = Reflect.get(this.projectsObj, xmdm) || { name: '通用评判' }
if (currentProject) {
currentProject.type = '4'
@ -658,11 +644,11 @@ struct Index {
const initData = strArr[0]
const beginData = strArr[1]
const initDataObj:JudgeInitObj = JSON.parse(initData)
const beginDataObj:JudgeBeginObj = JSON.parse(beginData)
const initDataObj: JudgeInitObj = JSON.parse(initData)
const beginDataObj: JudgeBeginObj = JSON.parse(beginData)
const examSubject = this.carInfo.examSubject;
this.examSubject =( isTrajectoryOpen ? (initDataObj.kskm) : examSubject) +'';
this.examSubject = (isTrajectoryOpen ? (initDataObj.kskm) : examSubject) + '';
this.carInfo.examSubject = this.examSubject
this.singlePlay = beginDataObj.exam == 0;
this.carName = initDataObj.name;
@ -677,11 +663,11 @@ struct Index {
const carInfo = this.carInfo
await uploadExamMileage({
carId:carInfo.carId,
examinationRoomId:carInfo.examinationRoomId,
lsh:this.lsh,
kskssj:this.startExamTime,
kslc:this.jl
carId: carInfo.carId,
examinationRoomId: carInfo.examinationRoomId,
lsh: this.lsh,
kskssj: this.startExamTime,
kslc: this.jl
})
}
}
@ -744,7 +730,7 @@ struct Index {
if (this.examSubject == "3") {
Row() {
if (Reflect.get(this.judgeConfigObj,'375') == '0') {
if (Reflect.get(this.judgeConfigObj, '375') == '0') {
Text(`应行驶:${this.examMileage}m`)
.fontColor('#E5CCA1')
.fontSize(this.FONTSIZE)
@ -761,7 +747,7 @@ struct Index {
Column() {
Row() {
Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE)
if (Reflect.get(this.judgeConfigObj,'342') == '0') {
if (Reflect.get(this.judgeConfigObj, '342') == '0') {
Text(`${this.dw}挡`).fontColor('#FFA500').fontSize(this.FONTSIZE).padding({ left: 15, right: 15 })
Text(`${this.sd}km/h`).fontColor('#FFA500').fontSize(this.FONTSIZE)
}
@ -771,7 +757,7 @@ struct Index {
Flex({ direction: FlexDirection.Column }) {
if (this.kfArr.length) {
List({ scroller: this.kfArrScroller }) {
ForEach(this.kfArr, (item:MarkRule) => {
ForEach(this.kfArr, (item: MarkRule) => {
ListItem() {
Column() {
Row() {
@ -840,7 +826,7 @@ struct Index {
if (this.examSubject == "2") {
Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) {
List({}) {
ForEach(chunkArr(this.projects, 2), (item:[ProjectInfo,ProjectInfo]) => {
ForEach(chunkArr(this.projects, 2), (item: [ProjectInfo, ProjectInfo]) => {
ListItem() {
Row() {
Row() {
@ -892,7 +878,7 @@ struct Index {
justifyContent: FlexAlign.SpaceBetween
}) {
List({}) {
ForEach(this.projects, (project:ProjectInfo) => {
ForEach(this.projects, (project: ProjectInfo) => {
ListItem() {
Text(project.name) {
}
@ -917,7 +903,7 @@ struct Index {
justifyContent: FlexAlign.SpaceAround
}) {
List() {
ForEach(this.artSubject3Projects, (item:string, index) => {
ForEach(this.artSubject3Projects, (item: string, index) => {
ListItem() {
}
.backgroundImage(
@ -1042,7 +1028,7 @@ struct Index {
// type: 1,
// name: 'button_media.wav'
// })
if (Reflect.get(this.judgeConfigObj,'353') == '0') {
if (Reflect.get(this.judgeConfigObj, '353') == '0') {
this.endPopupVisible = true
} else {
Prompt.showToast({
@ -1071,11 +1057,11 @@ struct Index {
//科目三人工扣分弹窗
if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj,'342') == '0') {
if (this.isDeductedPopShow && this.examSubject == '3' && Reflect.get(this.judgeConfigObj, '342') == '0') {
DeductedPopup({
defaultTabIndex: this.defaultTabIndex,
currentItems: Reflect.ownKeys(this.projectsObj).map(projectKey => {
const project:ProjectInfo = Reflect.get(this.projectsObj,projectKey)
const project: ProjectInfo = Reflect.get(this.projectsObj, projectKey)
return project.type == '2' ? project.projectCode : undefined
}).filter(project => project !== undefined),
markRules: this.manualMarkRules,
@ -1083,7 +1069,7 @@ struct Index {
this.isDeductedPopShow = false;
this.defaultTabIndex = 0;
},
confirmMark: async (itemno:string, serial:string) => {
confirmMark: async (itemno: string, serial: string) => {
clearTimeout(this.popTimer)
this.popTimer = null
this.popTimer = setTimeout(async () => {
@ -1126,7 +1112,7 @@ struct Index {
if (this.isAmplifyPopShow && this.examSubject == '3') {
AmplifyPopup({
amplifyImgIndex: this.amplifiedImgIndex,
confirmAmplify: async (amplify:AmplifyItem) => {
confirmAmplify: async (amplify: AmplifyItem) => {
clearTimeout(this.popTimer)
this.popTimer = null
this.popTimer = setTimeout(async () => {
@ -1155,7 +1141,7 @@ struct Index {
router.back()
return
}
if (Reflect.get(this.judgeConfigObj,'344') == 1) {
if (Reflect.get(this.judgeConfigObj, '344') == 1) {
Prompt.showToast({
message: '考试未结束,不允许手动退出!',
duration: 4000
@ -1221,7 +1207,7 @@ struct Index {
}
getProjectColor(project: ProjectInfo) {
const type = project.type;
const type = project.type;
switch (type) {
case '1':
return '#E6DECF';
@ -1250,16 +1236,16 @@ struct Index {
const artSubject3ProjectsCodesArr = this.artSubject3ProjectsCodesArr;
const projectsObj = this.projectsObj;
const projectCode = Reflect.get(artSubject3ProjectsCodesArr,index)
const projectCode = Reflect.get(artSubject3ProjectsCodesArr, index)
if (index === 5) {
console.info('surenjun 靠边停车状态=> ', getIsExitManualProject(index))
}
const currentProject:ProjectInfo = Reflect.get(projectsObj,projectCode)
const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode)
if (getIsExitManualProject(index)) {
// 正在进行的项目 取消项目
if (isManualProjectIn && currentProject.type == '2') {
//判断人工是否能取消项目 && 当前项目有扣分的不能取消
if (Reflect.get(this.judgeConfigObj,'340') == 1) {
if (Reflect.get(this.judgeConfigObj, '340') == 1) {
await this.judge.setJudgeItem(projectCode, 2);
Prompt.showToast({
message: '项目取消',
@ -1270,11 +1256,11 @@ struct Index {
}
// 靠边停车时候可以触发
if (Reflect.get(this.judgeConfigObj,'343') === '0') {
if (Reflect.get(this.judgeConfigObj, '343') === '0') {
const xmmcStr = this.xmmcStr;
if (xmmcStr == '无' || xmmcStr == '') {
//512[6] 人工项目按钮放大确认
const param512:string[] = (Reflect.get(this.judgeConfigObj,'512') || '').split(',');
const param512: string[] = (Reflect.get(this.judgeConfigObj, '512') || '').split(',');
console.info('surenjun', param512)
if (param512[6] !== '0') {
this.amplifiedImgIndex = index;
@ -1310,24 +1296,24 @@ struct Index {
const getProjectIsInRoad = this.getProjectIsInRoad;
const projectCode = artSubject3ProjectsCodesArr[index];
const currentProject:ProjectInfo = Reflect.get(projectsObj,projectCode)
const currentProject: ProjectInfo = Reflect.get(projectsObj, projectCode)
if (currentProject === undefined) {
return false
}
const projectType = currentProject.type;
//不允许人工触发的项目列表,以","分隔
const unExitManualProjects:string[] = Reflect.get(this.judgeConfigObj,'332').split(',') || [];
const unExitManualProjects: string[] = Reflect.get(this.judgeConfigObj, '332').split(',') || [];
//直线行驶中不进其他考试项目(0-否 1-是)
const param348:string = Reflect.get(this.judgeConfigObj,'348') || '0',
const param348: string = Reflect.get(this.judgeConfigObj, '348') || '0',
//里程不够允许手工点靠边停车0-否 1-是)
param387:string = Reflect.get(this.judgeConfigObj,'387') || '0',
param387: string = Reflect.get(this.judgeConfigObj, '387') || '0',
//里程不够不报靠边停车0-否+1-是+2-必考项目未完成且里程不够不报项目)
param319:string = Reflect.get(this.judgeConfigObj,'319') || '0',
param319: string = Reflect.get(this.judgeConfigObj, '319') || '0',
//人工项目是否能取消 1:可取消;
param340:string = Reflect.get(this.judgeConfigObj,'340') || '0',
param340: string = Reflect.get(this.judgeConfigObj, '340') || '0',
//307参数里设置的项目项目已经做过后续不能人工触发
param307:string[] = (Reflect.get(this.judgeConfigObj,'307') || '').split(',');
param307: string[] = (Reflect.get(this.judgeConfigObj, '307') || '').split(',');
//非行驶状态(没有速度),人工项目不能触发(按钮灰色)
if (carztStr === '停车') {
@ -1335,7 +1321,7 @@ struct Index {
}
//车上是否能进行人工操作(0-能1-不能人工评判2-不能人工进项目3-都不能)
if (Reflect.get(this.judgeConfigObj,'342') === '3' || Reflect.get(this.judgeConfigObj,'342') === '2') {
if (Reflect.get(this.judgeConfigObj, '342') === '3' || Reflect.get(this.judgeConfigObj, '342') === '2') {
return false
}
@ -1361,7 +1347,7 @@ struct Index {
return false
}
const project_9:ProjectInfo = Reflect.get(projectsObj,'9')
const project_9: ProjectInfo = Reflect.get(projectsObj, '9')
// 直线行驶中不进其他考试项目(0-否 1-是)
if (param348 == '0' && project_9.type == '2') {
return index === 0 ? true : false
@ -1390,14 +1376,14 @@ struct Index {
const num = lane.num;
const count = lane.count;
const param_3:string[] = (Reflect.get(this.judgeConfigObj,'514')?.split(',') || []);
const param_4:string[] = (Reflect.get(this.judgeConfigObj,'515')?.split(',') || []);
const param_10:string[] = (Reflect.get(this.judgeConfigObj,'516')?.split(',') || []);
const param_11:string[] = (Reflect.get(this.judgeConfigObj,'517')?.split(',') || []);
const param_9:string[] = (Reflect.get(this.judgeConfigObj,'518')?.split(',') || []);
const param_12:string[] = (Reflect.get(this.judgeConfigObj,'519')?.split(',') || []);
const param_3: string[] = (Reflect.get(this.judgeConfigObj, '514')?.split(',') || []);
const param_4: string[] = (Reflect.get(this.judgeConfigObj, '515')?.split(',') || []);
const param_10: string[] = (Reflect.get(this.judgeConfigObj, '516')?.split(',') || []);
const param_11: string[] = (Reflect.get(this.judgeConfigObj, '517')?.split(',') || []);
const param_9: string[] = (Reflect.get(this.judgeConfigObj, '518')?.split(',') || []);
const param_12: string[] = (Reflect.get(this.judgeConfigObj, '519')?.split(',') || []);
const projectRoads:ProjectRoads = {
const projectRoads: ProjectRoads = {
//直线行驶
param_3,
//变更车道
@ -1417,7 +1403,7 @@ struct Index {
if (road === '') {
return false
}
const currentProjectRoad:string[] = Reflect.get(projectRoads,`param_${projectCode}`)
const currentProjectRoad: string[] = Reflect.get(projectRoads, `param_${projectCode}`)
if (currentProjectRoad.length == 0) {
return true
}
@ -1425,7 +1411,7 @@ struct Index {
//设置了514-519参数只能在设置的路段触发对应项目
if (currentProjectRoad.includes(road)) {
//如果525为1则514-519设置的路段不能触发对应项目
if (Reflect.get(this.judgeConfigObj,'525') == '1') {
if (Reflect.get(this.judgeConfigObj, '525') == '1') {
return false
}
} else {
@ -1434,7 +1420,7 @@ struct Index {
//405参数为2是如果在最左侧车道超车项目不能触发;
if (projectCode == '10' &&
Reflect.get(this.judgeConfigObj,'405') == '2' &&
Reflect.get(this.judgeConfigObj, '405') == '2' &&
(num === count) &&
num > 0
) {
@ -1454,7 +1440,7 @@ struct Index {
getIsEndManualProject = (index: number) => {
const projectName = this.artSubject3Projects[index];
const projectCode = this.artSubject3ProjectsCodesArr[index];
const currentProject:ProjectInfo = Reflect.get(this.projectsObj,projectCode)
const currentProject: ProjectInfo = Reflect.get(this.projectsObj, projectCode)
const type = currentProject.type
if (type == '2') {
return projectName
@ -1465,10 +1451,10 @@ struct Index {
getIsManualKf = () => {
if (this.examSubject == '3') {
//杭州训练模式不允许人工评判
if (this.singlePlay && Reflect.get(this.judgeConfigObj,'211') == 'zjhz') {
if (this.singlePlay && Reflect.get(this.judgeConfigObj, '211') == 'zjhz') {
return false
}
if (Reflect.get(this.judgeConfigObj,'342') == '0') {
if (Reflect.get(this.judgeConfigObj, '342') == '0') {
return true
}
} else {

View File

@ -1,4 +1,5 @@
import libJudgeSdk from "libjudgesdk.so"
import libJudgeSdk from 'libjudgesdk.so';
import { JudgeInitObj } from '../../../model';
// import libJudgeSdk from '@ohos.judgesdk'
/**
@ -24,8 +25,8 @@ export async function examJudgeVersion(): Promise<string> {
* @params callBack 日志操作回调
* @desc 设置评判日志级别和日志回调函数
*/
export async function examJudgeSetLogCallback(level: number, handleLog: Function): Promise<string> {
const temp:number = libJudgeSdk.examJudgeSetLogCallback(level, handleLog);
export async function examJudgeSetLogCallback(level: number, handleLog: Function): Promise<number> {
const temp: number = libJudgeSdk.examJudgeSetLogCallback(level, handleLog);
return await handle(temp, 'examJudgeSetLogCallback')
}
@ -33,9 +34,9 @@ export async function examJudgeSetLogCallback(level: number, handleLog: Function
*
* @desc评判初始化
*/
export async function examJudgeInit(data) {
export async function examJudgeInit(data: JudgeInitObj) {
const str = JSON.stringify(data);
const temp:number = libJudgeSdk.examJudgeInit(str, str.length);
const temp: number = libJudgeSdk.examJudgeInit(str, str.length);
return await handle(temp, 'examJudgeInit')
}
@ -44,7 +45,7 @@ export async function examJudgeInit(data) {
* @desc 执行实时考试过程 实时传递传感信息
*/
export async function examJudgeRealExam(data) {
const temp:number = libJudgeSdk.examJudgeRealExam(JSON.stringify(data), str.length);
const temp: number = libJudgeSdk.examJudgeRealExam(JSON.stringify(data), str.length);
return await handle(temp, 'examJudgeRealExam')
}
@ -53,8 +54,8 @@ export async function examJudgeRealExam(data) {
* @desc 设置评判输出的考试过程数据回调函数
*/
//js_examJudgeSetRealExamCallback
export async function examJudgeSetRealExamCallback(fn:Function) {
const temp:number = libJudgeSdk.examJudgeSetRealExamCallback(fn);
export async function examJudgeSetRealExamCallback(fn: Function) {
const temp: number = libJudgeSdk.examJudgeSetRealExamCallback(fn);
return await handle(temp, 'examJudgeSetRealExamCallback')
}
@ -62,8 +63,8 @@ export async function examJudgeSetRealExamCallback(fn:Function) {
*
* @desc 设置轨迹图像回调函数
*/
export async function examJudgeMapImageSetCallback(fn:Function) {
const temp:number = libJudgeSdk.examJudgeMapImageSetCallback(fn);
export async function examJudgeMapImageSetCallback(fn: Function) {
const temp: number = libJudgeSdk.examJudgeMapImageSetCallback(fn);
return await handle(temp, 'examJudgeMapImageSetCallback')
}
@ -80,7 +81,7 @@ export async function examJudgeArtificialMark(
//扣分类型number
type: number
) {
const temp:number= libJudgeSdk.examJudgeArtificialMark(itemno, serial, type);
const temp: number = libJudgeSdk.examJudgeArtificialMark(itemno, serial, type);
return await handle(temp, 'examJudgeArtificialMark')
}
@ -94,7 +95,7 @@ export async function examJudgeArtificialItem(
//操作类型
type: number = 0
) {
const temp:number = libJudgeSdk.examJudgeArtificialItem(itemno, type);
const temp: number = libJudgeSdk.examJudgeArtificialItem(itemno, type);
return await handle(temp, 'examJudgeArtificialMark')
}
@ -103,8 +104,8 @@ export async function examJudgeArtificialItem(
*
* @desc 设置地图轨迹图像绘制的开关
*/
export async function examJudgeMapSetDrawing(bool:boolean) {
const temp:number = libJudgeSdk.examJudgeMapSetDrawing(bool);
export async function examJudgeMapSetDrawing(bool: boolean) {
const temp: number = libJudgeSdk.examJudgeMapSetDrawing(bool);
return await handle(temp, 'examJudgeMapSetDrawing')
}
@ -115,7 +116,7 @@ export async function examJudgeMapSetDrawing(bool:boolean) {
*/
export async function examJudgeBeginExam(data) {
const str = JSON.stringify(data);
const temp:number = libJudgeSdk.examJudgeBeginExam(str, str.length);
const temp: number = libJudgeSdk.examJudgeBeginExam(str, str.length);
return await handle(temp, 'examJudgeBeginExam')
}
@ -132,7 +133,7 @@ export async function examJudgeBeginExam(data) {
*
*/
export async function examJudgeEndExam() {
const temp:number = libJudgeSdk.examJudgeEndExam();
const temp: number = libJudgeSdk.examJudgeEndExam();
return await handle(temp, 'examJudgeEndExam')
}
@ -141,7 +142,7 @@ export async function examJudgeEndExam() {
*
*/
export async function examJudgeDestroy() {
const temp:number = libJudgeSdk.examJudgeDestroy();
const temp: number = libJudgeSdk.examJudgeDestroy();
return await handle(temp, 'examJudgeDestroy')
}
@ -150,7 +151,7 @@ export async function examJudgeDestroy() {
*
*/
export async function examJudgeMapSetParam(width: number, height: number) {
const temp:number = libJudgeSdk.examJudgeMapSetParam(width, height);
const temp: number = libJudgeSdk.examJudgeMapSetParam(width, height);
return await handle(temp, 'examJudgeMapSetParam')
}
@ -159,7 +160,7 @@ export async function examJudgeMapSetParam(width: number, height: number) {
*
*/
export async function examJudgeMapSetScaling(scaling?: number) {
const temp:number = libJudgeSdk.examJudgeMapSetScaling(scaling || 1);
const temp: number = libJudgeSdk.examJudgeMapSetScaling(scaling || 1);
return await handle(temp, 'examJudgeMapSetScaling')
}
@ -168,7 +169,7 @@ export async function examJudgeMapSetScaling(scaling?: number) {
*
*/
export async function examJudgeSetPerformCallback(fn) {
const temp:number = libJudgeSdk.examJudgeSetPerformCallback(fn);
const temp: number = libJudgeSdk.examJudgeSetPerformCallback(fn);
return await handle(temp, 'examJudgeSetPerformCallback')
}
@ -177,16 +178,19 @@ export async function examJudgeSetPerformCallback(fn) {
* @desc 语音播报结束
* /
*/
interface SoundParam{
interface SoundParam {
//项目代码
xmdm: number,
//语音码
code: string,
//语音类型
type: 0|1,
type: 0 | 1,
}
export async function examJudgeSoundEnd(param: SoundParam) {
const temp:number = libJudgeSdk.examJudgeSoundEnd(param.xmdm, param.code, param.type);
const temp: number = libJudgeSdk.examJudgeSoundEnd(param.xmdm, param.code, param.type);
return await handle(temp, 'examJudgeSoundEnd')
}
@ -195,15 +199,16 @@ export async function examJudgeSoundEnd(param: SoundParam) {
* @desc 实时距离计算
*
* */
interface DistanceParam{
interface DistanceParam {
jd1: number,
wd1: number,
jd2: number,
wd2: number,
h: number
}
export async function examCalcGpsDistance(param:DistanceParam):Promise<number> {
const temp:number = libJudgeSdk.examCalcGpsDistance(param.jd1, param.wd1, param.jd2, param.wd2, param.h);
export async function examCalcGpsDistance(param: DistanceParam): Promise<number> {
const temp: number = libJudgeSdk.examCalcGpsDistance(param.jd1, param.wd1, param.jd2, param.wd2, param.h);
return temp
}
@ -212,7 +217,7 @@ export async function examCalcGpsDistance(param:DistanceParam):Promise<number> {
* @desc通用处理函数
*
*/
async function handle(temp:number, fnName:string): Promise<string> {
async function handle(temp: number, fnName: string): Promise<number> {
return new Promise((resolve, reject) => {
if (temp == 0) {
resolve(temp);

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,12 @@
import media from '@ohos.multimedia.media';
import Prompt from '@system.prompt';
import url from '@ohos.url';
import fileuri from "@ohos.file.fileuri";
import mediaLibrary from '@ohos.multimedia.mediaLibrary';
import common from '@ohos.app.ability.common';
import { BusinessError } from '@ohos.base';
const TAG = 'VoiceAnnounce'
interface Queue{
interface Queue {
url: string,
callback?: Function
}
@ -32,13 +31,14 @@ export default class VoiceAnnounce {
const queue = this.queue;
const tempUrls: Queue[] = urls.map((url, index) => {
const callback:Function|undefined = (index === urls.length - 1) ? callbackFn : undefined
const temp:Queue = {url, callback}
const callback: Function | undefined = (index === urls.length - 1) ? callbackFn : undefined
const temp: Queue = {
url, callback
}
return temp
});
if (shit) {
//队列清空,重新初始化
this.isStopped = true;
@ -92,7 +92,7 @@ class AVPlayer {
}
// 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
async play(name:string, callback:Function):Promise<boolean> {
async play(name: string, callback: Function): Promise<boolean> {
try {
//检查SD中的语音
// console.info('surenjun name',name)
@ -144,7 +144,7 @@ class AVPlayer {
}
}
async queryFile(displayName:string): Promise<mediaLibrary.FileAsset> {
async queryFile(displayName: string): Promise<mediaLibrary.FileAsset> {
return new Promise(async (resolve, reject) => {
const context = AppStorage.get<common.UIAbilityContext>('context')
const mediaLib = mediaLibrary.getMediaLibrary(context);
@ -174,8 +174,9 @@ class AVPlayer {
}
// 注册avplayer回调函数
setAVPlayerCallback(callBack:Function) {
this.avPlayer.on('error', (err) => {
setAVPlayerCallback(callBack: Function) {
this.avPlayer.on('error', (err: BusinessError) => {
console.log(TAG, '播放器错误', JSON.stringify(err))
this.avPlayer && this.avPlayer.stop()
this.avPlayer && this.avPlayer.reset()
this.avPlayer && this.avPlayer.release()