diff --git a/entry/src/main/ets/api/userInfo.ets b/entry/src/main/ets/api/userInfo.ets index a67c3f0..e03dc9a 100644 --- a/entry/src/main/ets/api/userInfo.ets +++ b/entry/src/main/ets/api/userInfo.ets @@ -45,10 +45,10 @@ export async function faceCompare(params: FaceCompareParams) { } -export async function getExaminationStudentInfo(params: ESObject) { +export async function getExaminationStudentInfo(params: ExaminationStuAbsentParams) { return request({ url: '/der2/services/exam/getExaminationStudentInfo.ws', - data: params, + data: `${params.md5Message}${params.carId}${params.examinationRoomId}${params.username}`, method: http.RequestMethod.POST, xml: true }) diff --git a/entry/src/main/ets/model/UserInfo.ets b/entry/src/main/ets/model/UserInfo.ets index 960a4ba..0c1cb16 100644 --- a/entry/src/main/ets/model/UserInfo.ets +++ b/entry/src/main/ets/model/UserInfo.ets @@ -33,4 +33,47 @@ export interface CheckItemType { checkFn: (msgArr: number[]) => boolean; audio: string; message: string; -} \ No newline at end of file +} +// const SYSSET_VNO = { +// SERIAL_NUMBER: '901', +// EXAM_SYSTEM_CODE: '902', +// STUDENT_REFRESH: '452', +// OPEN_CHECK_FLAG: '17', +// FACE_PARAM: '2413', +// JUDGMENT_TIMING: '364', +// SECOND_EXAM_PREPARE: '398', +// NO_ABSENT_FUNCTION: '770', +// SEATBELT_DOOR: '803', +// EXAM_ORDER: '341', +// EXAM_TRIGGER: '612', +// NO_ABSENT_AFTER_ONCE: '352', +// EXAMINER_DISPLAY: '828', +// VIDEO_SAVE_DAYS: '305' +// }; +export const SYSSET_VNO_MAP=new Map([ + ['SERIAL_NUMBER', '901'], + ['EXAM_SYSTEM_CODE', '902'], + ['STUDENT_REFRESH', '452'], + ['OPEN_CHECK_FLAG', '17'], + ['FACE_PARAM', '2413'], + ['JUDGMENT_TIMING', '364'], + ['SECOND_EXAM_PREPARE', '398'], + ['NO_ABSENT_FUNCTION', '770'], + ['SEATBELT_DOOR', '803'], + ['EXAM_ORDER', '341'], + ['EXAM_TRIGGER', '612'], + ['NO_ABSENT_AFTER_ONCE', '352'], + ['EXAMINER_DISPLAY', '828'], + ['VIDEO_SAVE_DAYS', '305'] +]) +// // 定义更新策略常量 +// const REFRESH_STRATEGY = { +// NO_AUTO: '0', +// AUTO_UNLIMITED: '1', +// AUTO_TWICE: '2' +// }; +export const REFRESH_STRATEGY_MAP=new Map([ + ['NO_AUTO', '0'], + ['AUTO_UNLIMITED', '1'], + ['AUTO_TWICE', '2'] +]) \ No newline at end of file diff --git a/entry/src/main/ets/model/api.ets b/entry/src/main/ets/model/api.ets index 14ebdd9..3dae78c 100644 --- a/entry/src/main/ets/model/api.ets +++ b/entry/src/main/ets/model/api.ets @@ -276,9 +276,10 @@ interface GetExaminationItemRspBody { export interface ExaminationStuAbsentParams { carId: string; - sfzmhm: string; + sfzmhm?: string; examinationRoomId: string; username: string; - lsh: string; + lsh?: string; + md5Message?: string } diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index e4f7313..a95b50d 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -25,9 +25,11 @@ import { IdCard, LabelBlockType, MASYSSETTableType, + REFRESH_STRATEGY_MAP, RegulatoryInterfaceParams, RouteParamsType, SckType, + SYSSET_VNO_MAP, SystemParamType, UDPParamType, User @@ -362,7 +364,6 @@ struct UserInfoPage { }) this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) if (!flag) { - AppStorage.setOrCreate('lsh', '0000000000000') await SqlInsertTable('USER', []) setTimeout(() => { @@ -459,9 +460,6 @@ struct UserInfoPage { AppStorage.setOrCreate('examinerInfo', this.examinerLoginInfo) AppStorage.setOrCreate('lsh', this.lsh) } - - // const syssetParams = await getSyncData('MA_SYSSET'); - } async heartMsg() { @@ -484,117 +482,146 @@ struct UserInfoPage { } async initSysset() { - const that = this; - GetSyncData("MA_SYSSET").then((syssetParams: MASYSSETTableType[]) => { - const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901') - that.jkxlh = serialNumberArr?.[0]?.v_value || '' - const ksxtbhArr = syssetParams.filter(sys => sys.v_no === '902') - that.ksxtbh = ksxtbhArr?.[0]?.v_value || '222' - const studentRefreshParam = syssetParams.filter(sys => sys.v_no === '452') //判断自动更新 - that.studentRefreshStatue = studentRefreshParam?.[0]?.v_value || '0' - const openCheckFlagParam = syssetParams.filter(sys => sys.v_no == '17') //0 - const openCheckFlag = openCheckFlagParam?.[0]?.v_value == '1' ? '1' : '0' + // 使用 try-catch 处理可能的异常 + try { + const syssetParams = await GetSyncData("MA_SYSSET"); + // 创建映射表以避免多次 filter 操作 + const syssetMap = new Map(); + syssetParams.forEach(sys => syssetMap.set(sys.v_no!, sys)); - const faceParam = syssetParams.filter(sys => sys.v_no == '2413') //3 - dConsole.log('FaceOpenStatue', openCheckFlag, this.FaceOpenStatue) - // 1身份证读卡器 2指纹 3人脸 - if (openCheckFlag == '1') { - that.FaceOpenStatue = faceParam?.[0]?.v_value == '3' ? '1' : '0' - this.faceFlag = faceParam?.[0]?.v_value || '0' - if (faceParam?.[0]?.v_value == '1') { - that.openDeviceByIDCard() + // 使用映射表获取所需参数 + this.jkxlh = syssetMap.get(SYSSET_VNO_MAP.get('SERIAL_NUMBER')!)?.v_value || ''; + this.ksxtbh = syssetMap.get(SYSSET_VNO_MAP.get("EXAM_SYSTEM_CODE")!)?.v_value || '222'; + this.studentRefreshStatue = syssetMap.get(SYSSET_VNO_MAP.get("STUDENT_REFRESH")!)?.v_value || '0'; + + // 获取验证标志和人脸参数 + const openCheckFlagParam = syssetMap.get(SYSSET_VNO_MAP.get("OPEN_CHECK_FLAG")!); + const openCheckFlag = openCheckFlagParam?.v_value === '1' ? '1' : '0'; + const faceParam = syssetMap.get(SYSSET_VNO_MAP.get("FACE_PARAM")!); + + dConsole.log('FaceOpenStatue', openCheckFlag, this.FaceOpenStatue); + + // 处理人脸识别状态 + if (openCheckFlag === '1') { + const faceValue = faceParam?.v_value || '0'; + this.FaceOpenStatue = faceValue === '3' ? '1' : '0'; + this.faceFlag = faceValue; + + if (faceValue === '1') { + this.openDeviceByIDCard(); } } - // let a = await this.fileUtil.initFolder("/config/temptable") - // this.fileUtil.addFile("temp.log", JSON.stringify(syssetParams)) + + // 遍历处理系统参数 syssetParams.forEach(sys => { - //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) - if (sys.v_no === '364' && decodeURIComponent(sys.v_value || "") == '2') { - this.systemParam.Param364 = sys.v_value || "" - that.isBoardPrePareSetPopupOpen = true; - that.isFirstBoardPrePareSetPopupBtnShow = false + const vNo = sys.v_no; + const vValue = decodeURIComponent(sys.v_value || ''); + + switch (vNo) { + case SYSSET_VNO_MAP.get("JUDGMENT_TIMING"): + // 绕车一周评判时机 + if (vValue === '2') { + this.systemParam.Param364 = sys.v_value || ''; + this.isBoardPrePareSetPopupOpen = true; + this.isFirstBoardPrePareSetPopupBtnShow = false; + } + break; + + case SYSSET_VNO_MAP.get("SECOND_EXAM_PREPARE"): + // 第二场考试上车准备不考 + if (vValue === '1') { + this.systemParam.Param398 = vValue; + this.isSecondBoardPrePareSetPopupOpen = true; + } + break; + + case SYSSET_VNO_MAP.get("NO_ABSENT_FUNCTION"): + // 车上没有缺考功能 + this.systemParam.Param770Str = sys.v_value || ''; + break; + + case SYSSET_VNO_MAP.get("SEATBELT_DOOR"): + // 开始考试前必须解开安全带或关车门 + this.systemParam.Param803Str = sys.v_value + ''; + break; + + case SYSSET_VNO_MAP.get("EXAM_ORDER"): + // 判断是否考生是否按顺序考试 + this.systemParam.Param341 = vValue === '1'; + break; + + case SYSSET_VNO_MAP.get("EXAM_TRIGGER"): + // 开始考试触发方式 + this.systemParam.Param612Str = vValue; + break; + + case SYSSET_VNO_MAP.get("NO_ABSENT_AFTER_ONCE"): + // 车上考试过一次就不能缺考 + this.systemParam.Param352Str = vValue; + break; + + case SYSSET_VNO_MAP.get("EXAMINER_DISPLAY"): + // 考生待考界面,安全员显示考试员 + this.systemParam.Param828Str = vValue; + this.labelBlocks[5].label = vValue === '1' ? '安全员名' : '考试员名'; + // 使用 Array.from 创建新数组,避免使用扩展运算符 + this.labelBlocks = Array.from(this.labelBlocks); + break; + + case SYSSET_VNO_MAP.get("VIDEO_SAVE_DAYS"): + // 视频保存天数 + this.systemParam.Param305Str = vValue; + if (!Number(this.systemParam.Param305Str)) { + this.systemParam.Param305Str = '2'; + } + break; + } + }); + + // 处理考生刷新逻辑 + const handleStudentRefresh = () => { + // 清除旧的定时器 + if (this.interval) { + clearInterval(this.interval); + this.interval = -1; } - //398参数为1 第二场考试上车准备不考 - if (sys.v_no === '398' && decodeURIComponent(sys.v_value || "") == '1') { - that.systemParam.Param398 = decodeURIComponent(sys.v_value || "") - that.isSecondBoardPrePareSetPopupOpen = true; - } + // 如果列表为空,设置定时器 + if (this.list.length === 0) { + switch (this.studentRefreshStatue) { + case REFRESH_STRATEGY_MAP.get("AUTO_TWICE"): + this.interval = setInterval(() => { + if (this.numCount < 3) { + this.numCount++; + if (this.list.length === 0) { + this.getExaminationStudentInfoFn(); + } + } else { + clearInterval(this.interval); + this.interval = -1; + } + }, 5000); + break; - // 车上没有缺考功能 - if (sys.v_no === '770') { - that.systemParam.Param770Str = sys.v_value || ""; - } - // 开始考试前必须解开安全带或关车门 - if (sys.v_no === '803') { - that.systemParam.Param803Str = sys.v_value + ''; - } - //判断是否考生是否按顺序考试 - if (sys.v_no === '341' && decodeURIComponent(sys.v_value || "") == '1') { - that.systemParam.Param341 = true - } else { - //todo - that.systemParam.Param341 = true - } - //开始考试触发方式 - if (sys.v_no === '612') { - that.systemParam.Param612Str = decodeURIComponent(sys.v_value || "") - } - //车上考试过一次就不能缺考 - if (sys.v_no === '352') { - that.systemParam.Param352Str = decodeURIComponent(sys.v_value || "") - } - //828考生待考界面,安全员显示考试员 - if (sys.v_no === '828') { - that.systemParam.Param828Str = decodeURIComponent(sys.v_value || "") - if (that.systemParam.Param828Str == '1') { - that.labelBlocks[5].label = '安全员名' - } else { - that.labelBlocks[5].label = '考试员名' - } - that.labelBlocks = JSON.parse(JSON.stringify(this.labelBlocks)) - - } - //视频保存天数 - if (sys.v_no === '305') { - that.systemParam.Param305Str = decodeURIComponent(sys.v_value || "") - if (!Number(this.systemParam.Param305Str)) { - that.systemParam.Param305Str = '2' + case REFRESH_STRATEGY_MAP.get("AUTO_UNLIMITED"): + this.interval = setInterval(() => { + if (this.list.length === 0) { + this.getExaminationStudentInfoFn(); + } + }, 5000); + break; } } - }) + // 获取考生信息 + this.getExaminationStudentInfoFn(); + }; + handleStudentRefresh(); - //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 - if (that.studentRefreshStatue == '2') { - if (that.list.length == 0) { - clearInterval(that.interval) - that.interval = setInterval(() => { - if (that.numCount < 3) { - that.numCount++ - if (that.list.length == 0) { - that.getExaminationStudentInfoFn() - } - } - }, 5000) - } else { - that.getExaminationStudentInfoFn() - } - } else if (that.studentRefreshStatue == '1') { - if (that.list.length == 0) { - clearInterval(that.interval) - that.interval = setInterval(() => { - if (that.list.length == 0) { - that.getExaminationStudentInfoFn() - } - }, 5000) - } else { - that.getExaminationStudentInfoFn() - } - } else { - // this.getExaminationItemFn() - } - }) + } catch (error) { + dConsole.error('初始化系统设置失败:', error); + // 可以添加错误处理逻辑 + } } //人脸比对窗口关闭 @@ -632,7 +659,6 @@ struct UserInfoPage { this.isExamStart = false this.startExam = false this.updateTimeLimit = false - // this.isBoardPrePareSetPopupOpen=true this.isFirstBoardPrePareSetPopupBtnShow = false dConsole.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow, this.isBoardPrePareSetPopupOpen) @@ -643,8 +669,12 @@ struct UserInfoPage { let md5Message: string = CryptoJS.MD5(this.carInfo.carId! + this.carInfo.examinationRoomId! + this.examinerLoginInfo.username!).toString(); - const param = - `${md5Message}${this.carInfo.carId}${this.carInfo.examinationRoomId}${this.examinerLoginInfo.username}` + const param: ExaminationStuAbsentParams = { + md5Message: md5Message, + carId: this.carInfo.carId || "", + examinationRoomId: this.carInfo.examinationRoomId || "", + username: this.examinerLoginInfo.username || "" + } try { getExaminationStudentInfo(param).then(async (res) => { dConsole.log("temp log ", JSON.stringify(res)) @@ -946,7 +976,7 @@ struct UserInfoPage { this.stepFlag = false this.stopDeviceById() } catch (e) { - + dConsole.error(UserInfoTag, JSON.stringify(e)) } }