diff --git a/.gitignore b/.gitignore index 54d8f25e..a6da3e53 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ /.clangd /.clang-format /.clang-tidy +/entry/src/main/cpp /entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts /build-profile.json5 \ No newline at end of file diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 0015414e..040bcc5b 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -2,6 +2,8 @@ import { examinationStuAbsent, getExaminationItem, getExaminationStudentInfo } f import router from '@ohos.router'; import TopLogo from './compontents/TopLogo'; import Md5 from '../common/utils/md5'; +import AccountTable from '../common/database/tables/AccountTable'; +import USER from '../common/constants/USER'; import { dateFormat, getCurrentHourTime, getCurrentTime, string2Bytes } from '../common/utils/tools'; import FaceCompare from './compontents/FaceCompare'; // import { initJudgeUdp } from '../common/utils/UdpJudge' @@ -65,7 +67,6 @@ struct UserInfo { //是否已经开始考试 @State isExamStart: boolean = false; @State effectDate: string = ''; - @State errorNum: number = 0; @State interval: any = null; @State studentRefreshStatue: string = '0'; @State photo: string = 'data:image/bmp;base64,'; @@ -97,7 +98,7 @@ struct UserInfo { if (singlePlay) { return '' } else { - const { filePhoto } = this; + const {filePhoto} = this; const photoBase64 = await filePhoto.getPhoto(); return photoBase64 } @@ -118,7 +119,7 @@ struct UserInfo { this.ksksLimit = true if (globalThis.singlePlay) { - const { examSubject } = globalThis.carInfo; + const {examSubject} = globalThis.carInfo; this.currentUser.id = '0' await upDateTableByArray('USER', [this.currentUser]) router.pushUrl({ @@ -166,6 +167,8 @@ struct UserInfo { ) private filePhoto: FilePhoto private avPlayer + private AccountTable = new AccountTable(() => { + }, USER); private context = getContext(this) as common.UIAbilityContext; private labelBlocks = [ { label: '考生姓名', key: 'xm' }, @@ -201,6 +204,7 @@ struct UserInfo { if (!globalThis.singlePlay) { // @ts-ignore if (routerParam.type != 1) { + console.info('surenjun', 'Judge返回到UserInfo界面') // @ts-ignore this.list = await getSyncData('USERLIST') // @ts-ignore @@ -209,39 +213,62 @@ struct UserInfo { console.log('useruser1,', JSON.stringify(data)) const user = data[0] - if (user && Number(user.kssycs)) { - let flag = false - this.list.forEach(res => { - if (res.sfzmhm == user.sfzmhm) { - flag = true - res.kssycs = user.kssycs - this.getCurrentStudent(res.sfzmhm) - } - }) - if (!flag) { - this.currentUser = (this.list.length ? this.list[0] : EmptyCandidateObject) - } - } else if (user && (user.kssycs == '0' || user.kssycs == '')) { - console.log('datadatadatadata') + if (!Number(user.kssycs)) { this.list = this.list.filter(res => { return res.sfzmhm != user.sfzmhm }) - this.pageIndex = 0 - this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) - if (this.dataList.length) { - setTimeout(() => { - this.currentUser = this.dataList[0] - this.currentUser.ksy2 = globalThis.kgxm - globalThis.lsh = this.currentUser.lsh - }, 200) - } else { - this.currentUser = EmptyCandidateObject - } + } + this.pageIndex = 0 + this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) + if (this.dataList.length) { + setTimeout(() => { + this.currentUser = this.dataList[0] + this.currentUser.ksy2 = globalThis.kgxm + globalThis.lsh = this.currentUser.lsh + }, 200) + } else { + this.currentUser = EmptyCandidateObject + globalThis.lsh = '1111111111111' } this.list.forEach((res, index) => { res.id = index.toString() }) await upDateTableByArray('USERLIST', this.list || []) + + // if(this.) + // if (user && Number(user.kssycs)) { + // + // let flag = false + // this.list.forEach(res => { + // if (res.sfzmhm == user.sfzmhm) { + // flag = true + // res.kssycs = user.kssycs + // this.getCurrentStudent(res.sfzmhm) + // } + // }) + // if (!flag) { + // this.currentUser = (this.list.length ? this.list[0] : EmptyCandidateObject) + // globalThis.lsh = this.list.length?this.currentUser.lsh:'1111111111111' + // } + // } else if (user && (user.kssycs == '0' || user.kssycs == '')) { + // console.log('datadatadatadata') + // this.list = this.list.filter(res => { + // return res.sfzmhm != user.sfzmhm + // }) + // this.pageIndex = 0 + // this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) + // if (this.dataList.length) { + // setTimeout(() => { + // this.currentUser = this.dataList[0] + // this.currentUser.ksy2 = globalThis.kgxm + // globalThis.lsh = this.currentUser.lsh + // }, 200) + // } else { + // this.currentUser = EmptyCandidateObject + // globalThis.lsh = '1111111111111' + // } + // } + } else { await this.getExaminationStudentInfoFn() } @@ -309,7 +336,7 @@ struct UserInfo { globalThis.lsh = res.lsh globalThis.ksyh = res.ksy1sfzmhm - const { examSubject } = globalThis.carInfo; + const {examSubject} = globalThis.carInfo; // this.currentUser.kszp=this.photo+res.kszp // this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp if (globalThis.singlePlay) { @@ -336,7 +363,6 @@ struct UserInfo { setTimeout(() => { this.currentUser = this.list[0] this.currentUser.ksy2 = globalThis.kgxm - globalThis.lsh = this.currentUser.lsh }, 200) @@ -585,7 +611,14 @@ struct UserInfo { // this.getExaminationItemFn() } }) - + // const db = new AccountTable(() => { + // }, MA_SYSSET); + // db.getRdbStore(() => { + // db.query('0', (syssetParams) => { + // + // + // }) + // }) } //人脸比对窗口关闭 @@ -627,136 +660,153 @@ struct UserInfo { this.ksksLimit = false // this.isBoardPrePareSetPopupOpen=true this.isFirstBoardPrePareSetPopupBtnShow = false - console.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow, - this.isBoardPrePareSetPopupOpen) + console.log('isFirstBoardPrePareSetPopupBtnShow', this.isFirstBoardPrePareSetPopupBtnShow, this.isBoardPrePareSetPopupOpen) this.startExam = false // await upDateTableByArray('USER', []) // await upDateTableByArray('USERLIST', []) - // await DB.clearTable('USER') - // await DB.clearTable('USERLIST') - // this.type = '2' - // this.errorDialog.open() + this.type = '2' + this.errorDialog.open() this.updateTimeLimit = true - const param = `${Md5.Instance.get_md5(globalThis.carInfo.carId + - globalThis.carInfo.examinationRoomId + - globalThis.username)}${globalThis.carInfo.carId}${globalThis.carInfo.examinationRoomId}${globalThis.username}` - getExaminationStudentInfo(param).then(async (res) => { - this.errorNum=0 - console.log("temp log ", JSON.stringify(res)) - await DB.clearTable('USER') - await DB.clearTable('USERLIST') - // this.errorDialog.close() - setTimeout(() => { - this.updateTimeLimit = false - }, 3000) - // @ts-ignore - if (!res || res?.getExaminationStudentInfoRsp?.head?.resultCode == '1') { - this.dataList = [] - this.list = [] - return - } - let dataList = [] - this.list = [] - - // @ts-ignore - for (let key in res.getExaminationStudentInfoRsp.body) { + const param = `${Md5.Instance.get_md5(globalThis.carInfo.carId + globalThis.carInfo.examinationRoomId + globalThis.username)}${globalThis.carInfo.carId}${globalThis.carInfo.examinationRoomId}${globalThis.username}` + try { + getExaminationStudentInfo(param).then(async (res) => { + console.log("temp log ", JSON.stringify(res)) + await DB.clearTable('USER') + await DB.clearTable('USERLIST') + this.errorDialog.close() + setTimeout(() => { + this.updateTimeLimit = false + }, 3000) // @ts-ignore - const a = res.getExaminationStudentInfoRsp.body[key] - if (a instanceof Array) { - dataList = a - } else { - dataList = [a] + if (!res || res?.getExaminationStudentInfoRsp?.head?.resultCode == '1') { + this.dataList = [] + this.list = [] + return } - } - if (dataList.length) { - this.numCount = 0 - } + let dataList = [] + this.list = [] - this.list = JSON.parse(JSON.stringify(dataList)) - - console.log("temp list", JSON.stringify(this.list)) - this.list.forEach((listData, index) => { - //考过一次不允许切换学员 - if (listData.kssycs == '1') { - - this.startExam = true + // @ts-ignore + for (let key in res.getExaminationStudentInfoRsp.body) { + // @ts-ignore + const a = res.getExaminationStudentInfoRsp.body[key] + if (a instanceof Array) { + dataList = a + } else { + dataList = [a] + } } - listData.id = index.toString() - for (let i in listData) { - listData[i] = decodeURI(listData[i]) + if (dataList.length) { + this.numCount = 0 } - if (this.systemParam.Param828Str == '1' || this.systemParam.Param828Str == '2') { - // listData.ksy2=listData.ksy1; - listData.ksy2 = globalThis.kgxm - } else { - // listData.ksy2=listData.ksy2; - listData.ksy2 = globalThis.kgxm - } - listData.kszp = this.photo + listData.kszp - listData.ksmjzp = this.photo + listData.ksmjzp - }) - // await upDateTableByArray('USERLIST', this.list || []) - console.log("temp list", JSON.stringify(this.list)) + this.list = JSON.parse(JSON.stringify(dataList)) - await sqlInsertCommonFn("USERLIST", this.list || []) - dataList = this.list.length > 4 ? this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) : this.list; + console.log("temp list", JSON.stringify(this.list)) + this.list.forEach((listData, index) => { + //考过一次不允许切换学员 + if (listData.kssycs == '1') { - this.dataList = dataList - console.log("temp list", JSON.stringify(this.dataList)) + this.startExam = true + } + listData.id = index.toString() + for (let i in listData) { + listData[i] = decodeURI(listData[i]) + } + if (this.systemParam.Param828Str == '1' || this.systemParam.Param828Str == '2') { + // listData.ksy2=listData.ksy1; + listData.ksy2 = globalThis.kgxm + } else { + // listData.ksy2=listData.ksy2; + listData.ksy2 = globalThis.kgxm + } + listData.kszp = this.photo + listData.kszp + listData.ksmjzp = this.photo + listData.ksmjzp + }) - const user = this.dataList.filter(res => { - return res.kssycs == '1' - }) - if (this.dataList.length) { - if (user.length) { - setTimeout(() => { - this.currentUser = user[0] - this.currentUser.ksy2 = globalThis.kgxm - globalThis.lsh = this.currentUser.lsh - globalThis.ksyh = this.currentUser.ksy1sfzmhm - }, 200) - } else { + // await upDateTableByArray('USERLIST', this.list || []) + console.log("temp list", JSON.stringify(this.list)) + + await sqlInsertCommonFn("USERLIST", this.list || []) + dataList = this.list.length > 4 ? this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) : this.list; + + this.dataList = dataList + console.log("temp list", JSON.stringify(this.dataList)) + + const user = this.dataList.filter(res => { + return res.kssycs == '1' + }) + if (this.dataList.length) { + // if (user.length) { + // setTimeout(() => { + // this.currentUser = user[0] + // this.currentUser.ksy2 = globalThis.kgxm + // globalThis.lsh = this.currentUser.lsh + // globalThis.ksyh = this.currentUser.ksy1sfzmhm + // }, 200) + // } else { setTimeout(() => { this.currentUser = this.dataList[0] this.currentUser.ksy2 = globalThis.kgxm globalThis.ksyh = this.currentUser.ksy1sfzmhm globalThis.lsh = this.currentUser.lsh }, 200) + // } + } else { + this.currentUser = EmptyCandidateObject + globalThis.lsh = '1111111111111' } - } else { - this.currentUser = EmptyCandidateObject - } - //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) - if (this.systemParam.Param364 == '2') { - this.isBoardPrePareSetPopupOpen = true; - this.isFirstBoardPrePareSetPopupBtnShow = false; - } + // const flag=dataList.filter((res)=>{ + // return res.sfzmhm==this.currentUser.sfzmhm + // }).length?true:false + // if(!this.currentUser.sfzmhm||this.currentUser.kssycs=='0'||!flag){ + // if (this.dataList.length) { + // setTimeout(()=>{ + // this.currentUser = this.dataList[0] + // this.currentUser.ksy2= globalThis.kgxm + // globalThis.lsh=this.currentUser.lsh + // },200) + // console.log('this.currentUser1',JSON.stringify(this.currentUser)) + // } else { + // this.currentUser = EmptyCandidateObject + // } + // } - //398参数为1 第二场考试上车准备不考 - if (this.systemParam.Param398 == '1') { - this.isSecondBoardPrePareSetPopupOpen = true; - } - this.pageIndex = 0 - // getSyncData('USER').then(data => { - // if (data?.[0]) { - // this.getCurrentStudent(data[0].sfzmhm) - // } - // }) - }).catch((error) => { + // this.lsh = this.currentUser.lsh + // globalThis.lsh = this.lsh + // globalThis.ksyh = this.currentUser.ksy1sfzmhm + + //364 绕车一周评判时机(1-开始考试后判 2-开始考试前判) + if (this.systemParam.Param364 == '2') { + this.isBoardPrePareSetPopupOpen = true; + this.isFirstBoardPrePareSetPopupBtnShow = false; + } + + //398参数为1 第二场考试上车准备不考 + if (this.systemParam.Param398 == '1') { + this.isSecondBoardPrePareSetPopupOpen = true; + } + + this.pageIndex = 0 + getSyncData('USER').then(data => { + if (data?.[0]) { + this.getCurrentStudent(data[0].sfzmhm) + } + }) + }).catch((error) => { + this.updateTimeLimit = false + this.errorDialog.close() + console.log('error12error' + error) + }) + } catch (error) { this.updateTimeLimit = false - // this.errorDialog.close() - this.errorNum++ - if (this.errorNum < 3) { - this.getExaminationStudentInfoFn() - } - console.log('error12error' + error) - }) - + this.errorDialog.close() + console.log('error14error' + error) + } } qkFn() { @@ -770,8 +820,7 @@ struct UserInfo { return } console.log('JsonJson', JSON.stringify(this.currentUser)) - const param = - `${globalThis.carInfo.carId}${this.currentUser.sfzmhm}${globalThis.carInfo.examinationRoomId}${globalThis.username}${this.lsh}` + const param = `${globalThis.carInfo.carId}${this.currentUser.sfzmhm}${globalThis.carInfo.examinationRoomId}${globalThis.username}${this.lsh}` console.log('carNo1111', param) examinationStuAbsent(param).then(res => { @@ -807,7 +856,7 @@ struct UserInfo { return } const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo; + const {carId,examinationRoomId} = carInfo; const examItems = await getExaminationItem({ time: getCurrentTime(), carId, @@ -829,7 +878,7 @@ struct UserInfo { globalThis.statue = 4 this.stepFlag = true const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo; + const {carId,examinationRoomId} = carInfo; let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } }; if (!globalThis.singlePlay) { //获取已考项目 @@ -847,7 +896,7 @@ struct UserInfo { avPlayer.playAudio([`voice/监管通信中.mp3`], false, async () => { console.info('surenjun', '播放结束开始考试接口调用') - const { code, keystr, message } = await this.beginExam() || {}; + const {code,keystr,message} = await this.beginExam() || {}; console.info('surenjun', '开始考试接口调用结束') // console.info('surenjun',code +'') //@ts-ignore TODO code转换 @@ -884,8 +933,8 @@ struct UserInfo { // 检测车门、熄火信号 async checkSignal(): Promise { - const { isCheckFireOpen } = judgeConfig - const { systemParam, isBoardPrePareSetPopupOpen } = this; + const {isCheckFireOpen} = judgeConfig + const {systemParam,isBoardPrePareSetPopupOpen} = this; const Param803Str = systemParam.Param803Str if (Param803Str === '') { return true @@ -990,8 +1039,8 @@ struct UserInfo { // 开始考试 async beginExam() { const carInfo = globalThis.carInfo; - const { carId, examinationRoomId } = carInfo; - const { examSubject, plateNo } = carInfo; + const {carId,examinationRoomId} = carInfo; + const { examSubject,plateNo } = carInfo; const date = new Date() globalThis.startHourTime = await getCurrentHourTime() const photoBase64 = await this.getPhoto(); @@ -1095,13 +1144,11 @@ struct UserInfo { } .width(165 * this.ratio) .height(85 * this.ratio) - .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : - $r('app.media.userboxbg')) + .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg')) .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(() => { console.log('this.startExam', this.startExam, this.systemParam.Param364, this.isExamStart) - if ((this.isExamStart && !globalThis.singlePlay && this.systemParam.Param341) || - (this.startExam && this.systemParam.Param364 == '2')) { + if (this.startExam && this.systemParam.Param364 == '2') { return } this.currentUser = EmptyCandidateObject @@ -1175,6 +1222,9 @@ struct UserInfo { // .commStyle() imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.yydj_btn') }) .margin({ bottom: 12 * this.ratio }) + .onClick(() => { + globalThis.judgeUdp.askVoice() + }) // Image($r('app.media.gx_btn')) // .commStyle() @@ -1196,17 +1246,14 @@ struct UserInfo { .onClick(() => { // this.avPlayer.playAudio(['button_media.wav']) // 已开始考试不能缺考 已考过一次学员不能缺考 车上不能缺考 - if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') || - this.systemParam.Param770Str == '1') { + if (this.ksksLimit || (this.systemParam.Param352Str == '1' && this.currentUser.kssycs == '1') || this.systemParam.Param770Str == '1') { return } this.ksksLimit = true this.qkFlag = true }) - if (this.isBoardPrePareSetPopupOpen && - (this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') && - !this.isFirstBoardPrePareSetPopupBtnShow) { + if (this.isBoardPrePareSetPopupOpen && (this.isSecondBoardPrePareSetPopupOpen && this.currentUser.kssycs == '2') && !this.isFirstBoardPrePareSetPopupBtnShow) { //上车准备 // Image($r('app.media.sczb_btn')).commStyle() imageBtn({ btnWidth: 220 * this.ratio, btnHeight: 69 * this.ratio, imgSrc: $r('app.media.sczb_btn') })