From 9082c5169c99e49a8051b0eedf91a18894a5cce0 Mon Sep 17 00:00:00 2001 From: surenjun Date: Wed, 28 Aug 2024 16:39:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat=EF=BC=9A=E8=AF=84=E5=88=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/common/service/voiceService.ts | 4 +- .../src/main/ets/common/utils/GetDistance.ts | 2 +- entry/src/main/ets/common/utils/request.ts | 10 ++- .../src/main/ets/entryability/EntryAbility.ts | 8 +- entry/src/main/ets/pages/Judge.ets | 1 + entry/src/main/ets/pages/UserInfo.ets | 1 + entry/src/main/ets/pages/judgeSDK/judge.ts | 78 ++++++++++--------- 7 files changed, 58 insertions(+), 46 deletions(-) diff --git a/entry/src/main/ets/common/service/voiceService.ts b/entry/src/main/ets/common/service/voiceService.ts index 19c4082e..71703eb2 100644 --- a/entry/src/main/ets/common/service/voiceService.ts +++ b/entry/src/main/ets/common/service/voiceService.ts @@ -92,13 +92,13 @@ export class voiceService { } // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例 avPlayerFdSrc(name) { - - globalThis.context.resourceManager.getRawFd(name, (error, value) => { + globalThis.context.resourceManager.getRawFd(name,async (error, value) => { if (error != null) { console.log(`jiangsong callback getRawFd failed error code: ${error.code}, message: ${error.message}.`); } else { console.log('jiangsongjiangsong',this.avPlayer) if (this.avPlayer) { + await this.avPlayer.reset() this.avPlayer.fdSrc = value; } diff --git a/entry/src/main/ets/common/utils/GetDistance.ts b/entry/src/main/ets/common/utils/GetDistance.ts index 916457a9..7d3f5f6c 100644 --- a/entry/src/main/ets/common/utils/GetDistance.ts +++ b/entry/src/main/ets/common/utils/GetDistance.ts @@ -42,7 +42,7 @@ export default class GetDistance { const content = await fileUtil.readFile(`${folderPath}/${date}.txt`) || ''; const contentArr = content.split('\n').filter(item => item) console.info('surenjun contentArr',JSON.stringify(contentArr)) - this.totalDistance += str * 1 + this.totalDistance += (str * 1 > 200 ? 200 : str*1) this.totalTime += 1; contentArr[contentArr.length - 1] = `程序启动时间:${timeStr} 累计行驶距离:${(this.totalDistance).toFixed(2)}m 累计运行时常:${Math.ceil(this.totalTime/60)}min`+ '\n' console.info('surenjun',contentArr.join('\n')) diff --git a/entry/src/main/ets/common/utils/request.ts b/entry/src/main/ets/common/utils/request.ts index 42e33456..2439db55 100644 --- a/entry/src/main/ets/common/utils/request.ts +++ b/entry/src/main/ets/common/utils/request.ts @@ -62,6 +62,7 @@ export default async function request(req: any) { //处理中心服务code if(res.Envelope){ const msgXml = res.Envelope.Body.writeObjectOutResponse.return; + //Envelope.Body.writeObjectOutResponse.return const dd = handleCenterCode(msgXml,isNewCenter); return dd } @@ -165,12 +166,14 @@ function handleCenterCode(msgXml,isNewCenter){ } //正则匹配code message字段 - const [code,message] = [/(.*)<\/code>/i,/(.*)<\/message>/i].map(pattern=>{ + const [code,message,keystr] = [/(.*)<\/code>/i,/(.*)<\/message>/i,/(.*)<\/keystr>/i].map(pattern=>{ const patternArr = pattern.exec(msgXml); return patternArr[1] }); - if(code === ''){ + console.info('surenjun =>request-prev',keystr) + + if(code != '1'){ prompt.showToast({ message: decodeURIComponent(message as string), duration: 3000 @@ -180,7 +183,8 @@ function handleCenterCode(msgXml,isNewCenter){ // globalThis.errorDialog.open() return {code,message:decodeURIComponent(message)} }else{ - return { code } + console.info('surenjun =>request',keystr) + return { code ,keystr, message } } } diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 643a1add..302f2fa1 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -30,10 +30,10 @@ export default class EntryAbility extends UIAbility { globalThis.hasAuth = false // globalThis.version = '2022.08.13.01'//洛阳 // globalThis.judgeVersion = '2022.12.05.1' - globalThis.judgeVersion = '2022.12.05.1' - globalThis.version = '2022.08.13.01' - // globalThis.version = '2024.11.22.14'//济南 - // globalThis.judgeVersion = '2024.11.22.14' + // globalThis.judgeVersion = '2022.12.05.1' + // globalThis.version = '2022.08.13.01' + globalThis.version = '2024.11.22.14'//济南 + globalThis.judgeVersion = '2024.11.22.14' globalThis.videoVersion= '1.0' // globalThis.version = '2023.12.13.01' // globalThis.judgeVersion = '2023.09.30.1' diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index f9fdd5b6..1ef0283d 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -295,6 +295,7 @@ struct Index { this.projectsCenterObj[txt2] = currentProject this.projects.push(currentProject); console.info('surenjun txt2=>',txt2) + //真实监管下发考试项目 if(isInExam && !kStringArr.includes(txt2)){ this.projectsObj[no2*1].type = '3' diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 49d500f5..cbf8356c 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -650,6 +650,7 @@ struct UserInfo { message, duration: 4000 }) + avPlayer.playAudio(['voice/监管审核未通过.mp3']); return } this.currentUser.id = '0' diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index 0e267d68..e1aae06b 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -179,24 +179,15 @@ export default class Judge { handDistance(); } }) - //TODO 监听远程扣分 } - - + //实时计算gps经纬度距离 handDistance= async ()=>{ const {jd,wd,hxj,dwzt} = this.tempData.gps; const tJD = convertGpsCoord2(jd) const tWD = convertGpsCoord2(wd) const {prevJd,prevWd} = this - console.info('surenjun =>prevJd',prevJd) - console.info('surenjun =>dwzt',dwzt) if(prevJd && dwzt == 4){ - console.info('surenjun =>tJD',tJD) - console.info('surenjun =>tWD',tWD) - console.info('surenjun =>prevJd',prevJd) - console.info('surenjun =>preWd',prevWd) - console.info('surenjun =>hxj',hxj) const distance = await examCalcGpsDistance({ jd1:prevJd, wd1:prevWd, @@ -204,7 +195,6 @@ export default class Judge { wd2:tWD, h:hxj || 1, }) - console.info('surenjun =>distance',distance) //@ts-ignore globalThis.distanceClass.setTimeData(((distance / 100).toFixed(2)) * 1) } @@ -802,18 +792,9 @@ export default class Judge { //及格分 let passingGrade = passingScore if (isManual) { - if (isAllProjectsEnd) { - // 考试合格 - if (totalScore >= passingGrade) { - // 考试合格 - await examJudgeEndExam(); - this.isExamEnd = true - } - } else { - // 考试不合格 - await examJudgeEndExam() - this.isExamEnd = true - } + // 考试不合格 + await examJudgeEndExam() + this.isExamEnd = true this.isManual = true } else { const param302 = judgeConfigObj['302']; @@ -824,17 +805,30 @@ export default class Judge { if (singlePlay) { console.info(judgeTag + ' isAllProjectsEnd => ',isAllProjectsEnd) if (isAllProjectsEnd) { - if (examSubject == 3 && (param342 == 0 || param342 == 2) && (param302 != 6 || param302 != 7 || param302 != 8)) { - if(param512[7] != 0){ - avPlayer.playAudio(['voice/综合评判.mp3']) - this.judgeUI.isDeductedPopShow = true - this.judgeUI.defaultTabIndex = 1 - this.isEndTip = true - } - } else { - await examJudgeEndExam() - this.isExamEnd = true - } + //成绩合格 + if(totalScore >= passingGrade && !isEndTip) { + if (examSubject == 3 && (param342 == 0 || param342 == 2) && (param302 != 6 || param302 != 7 || param302 != 8)) { + if(param512[7] != 0){ + avPlayer.playAudio(['voice/综合评判.mp3']) + this.judgeUI.isDeductedPopShow = true + this.judgeUI.defaultTabIndex = 1 + this.isEndTip = true + return + } + } else { + await examJudgeEndExam() + this.isExamEnd = true + return + } + }else{ + if(examSubject == 3 && param302 == 4){ + await examJudgeEndExam() + this.isExamEnd = true + return + } + } + await examJudgeEndExam() + this.isExamEnd = true } } else { //成绩不合格 @@ -850,6 +844,11 @@ export default class Judge { } //成绩合格 if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { + if(examSubject == 2){ + await examJudgeEndExam() + this.isExamEnd = true + return + } //考试合格自动退出 if(examSubject == 3 && param302 == 4){ await examJudgeEndExam() @@ -955,8 +954,15 @@ export default class Judge { dwlc: [d1,d2,d3,d4,d5].map((d,index) => `${index+1},${Math.floor(d /100)}`).join(';'), } } - const temp = await writeObjectOut(data,filePath); - promptWxCode('17C56', temp.code) + const {code,keystr,message} = await writeObjectOut(data,filePath); + promptWxCode('17C56', code) + + if(code != 1){ + avPlayer.playAudio(['voice/监管失败.mp3']) + this.isUdpEnd = true + router.back(); + return + } console.info(judgeTag, '考试结束 end') const param302 = judgeConfigObj['302']; judgeUI.loadingPopupVisible = true; From ca8a535eabc211e78fc2c23bc2e1b4d00e8263d9 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 09:04:23 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=88=AA=E9=99=A4=E5=9C=96=E7=89=87?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index ad9df068..e1a31134 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -431,7 +431,6 @@ struct Index { async initParams() { console.log('kkkkmmm') - delHilog() // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') //设置plc udp 同步requesthost await getUDP(this.context, false) @@ -459,6 +458,7 @@ struct Index { this.heartMsg() } }, 1000) + delHilog() //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] From a4065dde4cf77472ca92e72321699bbc3f81e5b8 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 10:16:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?tcp=E9=A9=97=E8=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/TcpClient.ts | 4 ++-- entry/src/main/ets/pages/Index.ets | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 110c9c08..f3380498 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -195,7 +195,7 @@ export default class TcpClient { } clearInterval(globalThis.intervaltcp) globalThis.intervaltcp=setInterval(()=>{ - setTimeout(async () => { + // setTimeout(async () => { //程序断开 if (globalThis.tcpUdpError) { console.log(TAG,'tcp信号丢失') @@ -206,7 +206,7 @@ export default class TcpClient { }); } globalThis.tcpUdpError = true; - }, 2000) + // }, 2000) },3000) // callback(value.message) }); diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index e1a31134..14704146 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -12,6 +12,7 @@ import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService'; +import { getUserAlbumItemByDisplayName } from '../common/service/videoService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' @@ -459,6 +460,7 @@ struct Index { } }, 1000) delHilog() + // getUserAlbumItemByDisplayName() //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] From 77ddbc9c1f4f9456b8defdb38bbf7b89662272e2 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 12:30:17 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=8B=8D=E7=85=A7=E9=8C=84=E5=83=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/common/service/videoService.ts | 12 +++++++----- entry/src/main/ets/common/utils/TcpClient.ts | 2 -- .../main/ets/common/utils/UdpClientByCenter.ts | 16 ++++++++-------- entry/src/main/ets/entryability/EntryAbility.ts | 4 ++-- entry/src/main/ets/pages/Index.ets | 9 ++++----- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index be4b22f7..eb3b2542 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -33,7 +33,7 @@ const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI, // const rtsp_server = record.createServer(); -export async function startRecordVideo(param, td, context, dir, path?) { +export async function startRecordVideo(param, td, context, dir, path?,index?) { return new Promise(async (reslove, reject) => { // const fileUtil = new FileUtil(globalThis.context) // const date=dateFormat(new Date).split(' ')[0] @@ -47,7 +47,7 @@ export async function startRecordVideo(param, td, context, dir, path?) { if (!path) { fileName = `movie_record${num}.mp4` } else { - fileName = `${path}.mp4` + fileName = `${path}_${index||num}.mp4` } // @ts-ignore @@ -101,18 +101,18 @@ export async function saveStartRecordVideo(path) { if (param['videoRecord'+i]) { console.log('pathpath0',path) - record_handle[i] = await getfilehandleCode(i, param, date, path) + record_handle[i] = await getfilehandleCode(i, param, date, path,i) } } reslove(record_handle) }) } -async function getfilehandleCode(td, param, dir, path) { +async function getfilehandleCode(td, param, dir, path,index) { return new Promise(async (reslove, reject) => { console.log('pathpath1',path) - const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path) + const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path,index) // this.rocordHandleObj['rocord_handle'+td] = record_handle reslove(record_handle) }) @@ -137,6 +137,8 @@ export async function getUserAlbumItemByDisplayName(displayName: string): Promis console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); if (fetchResult.getCount() > 0) { const albums = await fetchResult.getLastObject(); + console.log('get getUserAlbumItemByDisplayName album111',albums.albumName) + if(isSevenDaysAgo(albums.albumName)){ deleteAllFileByPiC(albums.albumName,2) } diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index f3380498..eea1e52d 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -195,7 +195,6 @@ export default class TcpClient { } clearInterval(globalThis.intervaltcp) globalThis.intervaltcp=setInterval(()=>{ - // setTimeout(async () => { //程序断开 if (globalThis.tcpUdpError) { console.log(TAG,'tcp信号丢失') @@ -206,7 +205,6 @@ export default class TcpClient { }); } globalThis.tcpUdpError = true; - // }, 2000) },3000) // callback(value.message) }); diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index bef8ac0d..87156197 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -343,10 +343,10 @@ export default class UdpClientByCenter { // this.stashFn(str) const newArr = JSON.parse(JSON.stringify(strachArr)) - // this.writeLog({ - // time:dateFormat(new Date()), - // PLC: JSON.stringify(newArr.toString()), - // }) + this.writeLog({ + time:dateFormat(new Date()), + PLC: JSON.stringify(newArr.toString()), + }) if(strachArr[83]!='4'){ this.chafenFlag++ if(this.chafenFlag>=15&&!globalThis.dialogOpen){ @@ -393,10 +393,10 @@ export default class UdpClientByCenter { this.testIfUdpConnetced(callback) } async writeLog(param){ - // const fileUtil = new FileUtil(globalThis.context) - // const date=dateFormat(new Date).split(' ')[0] - // const folderPath = await fileUtil.initFolder(`/PLC/${date}`); - // fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`) + const fileUtil = new FileUtil(globalThis.context) + const date=dateFormat(new Date).split(' ')[0] + const folderPath = await fileUtil.initFolder(`/PLC/${date}`); + fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`) } //获取当前UDP信号 diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 643a1add..b587e5d0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -59,8 +59,8 @@ export default class EntryAbility extends UIAbility { const windowClass = await windowStage.getMainWindow(); globalThis.windowClass = windowClass - // await windowClass.setWindowLayoutFullScreen(true) - await windowClass.setWindowSystemBarEnable([]) //全屏 + await windowClass.setWindowLayoutFullScreen(true) + // await windowClass.setWindowSystemBarEnable([]) //全屏 // await windowClass.setWindowSystemBarEnable(['navigation']) windowStage.loadContent('pages/Index', (err, data) => { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 14704146..43beacc4 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,4 +1,3 @@ -// @ts-nocheck import common from '@ohos.app.ability.common'; import router from '@ohos.router'; import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'; @@ -12,7 +11,6 @@ import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService'; -import { getUserAlbumItemByDisplayName } from '../common/service/videoService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' @@ -21,6 +19,7 @@ import errorMsgDialog from './compontents/errorMsgDialog' import { getSyncData } from '../common/service/initable'; import GetDistance from '../common/utils/GetDistance' import UIAbility from '@ohos.app.ability.UIAbility'; +import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; @@ -46,8 +45,6 @@ struct Index { private vocObj = null; private workerInstance = null; private context = getContext(this) as common.UIAbilityContext; - private title = '' - private type = '2' errorDialog: CustomDialogController = new CustomDialogController({ builder: errorMsgDialog({ title: globalThis.title, @@ -331,6 +328,7 @@ struct Index { workerInstance.postMessage(param); workerInstance.onmessage = (e: MessageEvents): void => { console.log("baoyihu after postMessage :", JSON.stringify(e.data)); + // @ts-ignore let workData: WorkData = e.data; if (workData.isComplete) { router.pushUrl({ @@ -379,6 +377,7 @@ struct Index { console.log('globalThis.singlePlay', globalThis.singlePlay) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { this.context.resourceManager.getRawFileContent("welcome.wav").then(value => { + console.log('tttttttt') this.vocObj.playAudio({ type: 1, name: 'welcome.wav' @@ -460,7 +459,7 @@ struct Index { } }, 1000) delHilog() - // getUserAlbumItemByDisplayName() + getUserAlbumItemByDisplayName('') //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] From c612ff8afd89a3df95e043549ebf9cfd1054f8b8 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Mon, 2 Sep 2024 18:23:00 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=E5=8E=BB?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/UserInfo.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 49d500f5..69f50d1e 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -389,7 +389,7 @@ struct UserInfo { db.getRdbStore(() => { db.query('0', (syssetParams) => { const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901') - that.jkxlh = serialNumberArr?.[0]?.v_value || '1234567' + 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') //判断自动更新 @@ -799,7 +799,7 @@ struct UserInfo { drvexam, xtlb: '17', //接口序列号 - jkxlh: this.jkxlh || '1234567', + jkxlh: this.jkxlh || '', //接口标识 jkid: '17C51', } From 6ecddd7cbf7db0d82c6d9d8b238f7c0ccebb70d6 Mon Sep 17 00:00:00 2001 From: surenjun Date: Mon, 2 Sep 2024 19:23:56 +0800 Subject: [PATCH 6/6] =?UTF-8?q?feat=EF=BC=9A=E8=AF=84=E5=88=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/common/service/timeService.ts | 11 ++-- entry/src/main/ets/common/utils/GlobalUdp.ts | 3 +- entry/src/main/ets/common/utils/UdpJudge.ts | 7 +-- entry/src/main/ets/common/utils/tools.ts | 14 +++++- .../src/main/ets/entryability/EntryAbility.ts | 8 +-- entry/src/main/ets/pages/Judge.ets | 39 +++++++++++---- entry/src/main/ets/pages/UserInfo.ets | 3 +- entry/src/main/ets/pages/judgeSDK/judge.ts | 50 +++++++++++++------ .../ets/pages/judgeSDK/utils/judgeConfig.ts | 2 +- 9 files changed, 95 insertions(+), 42 deletions(-) diff --git a/entry/src/main/ets/common/service/timeService.ts b/entry/src/main/ets/common/service/timeService.ts index 4b2704af..4ee97cf9 100644 --- a/entry/src/main/ets/common/service/timeService.ts +++ b/entry/src/main/ets/common/service/timeService.ts @@ -24,11 +24,12 @@ export async function setCurrentTime():Promise { let times = new Date(currentTime).getTime(); console.log('jiangsong:times==' + times); try { - systemTime.setTime(times).then(() => { - console.info(`Succeeded in setting time.`); - }).catch((error) => { - console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); - }); + await systemTime.setTime(times) + // systemTime.setTime(times).then(() => { + // console.info(`Succeeded in setting time.`); + // }).catch((error) => { + // console.info(`Failed to set time. message: ${error.message}, code: ${error.code}`); + // }); } catch(e) { console.info(`Failed to set time. message: ${e.message}, code: ${e.code}`); } diff --git a/entry/src/main/ets/common/utils/GlobalUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts index 24fc9119..6cb7052f 100644 --- a/entry/src/main/ets/common/utils/GlobalUdp.ts +++ b/entry/src/main/ets/common/utils/GlobalUdp.ts @@ -298,7 +298,8 @@ export async function setJudgeUdp() { if (config && config.udplocalIp) { const {udplocalIp} = config; - const udpClientbyCenter: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080', globalThis.carInfo?.gpsAddress, globalThis.carInfo?.hintPort) + const udpClientbyCenter: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080', globalThis.carInfo?.udpAddress, globalThis.carInfo?.hintPort) + await udpClientbyCenter.onError_Callback(()=>{}) await udpClientbyCenter.bindUdp() await udpClientbyCenter.onMessage_2((val) => {}) diff --git a/entry/src/main/ets/common/utils/UdpJudge.ts b/entry/src/main/ets/common/utils/UdpJudge.ts index d4f70362..0c366bf4 100644 --- a/entry/src/main/ets/common/utils/UdpJudge.ts +++ b/entry/src/main/ets/common/utils/UdpJudge.ts @@ -43,11 +43,8 @@ export const initJudgeUdp = async () => { wd2:wd, h:msgArr[90]*1 || 1, }) - if(distance < 1){ - return - } //@ts-ignore - globalThis.distanceClass.setTimeData(((distance / 100).toFixed(2)) * 1) + globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) } prevJd = jd; preWd = wd; @@ -66,7 +63,7 @@ export const getMessageHeartbeat = async (msg) => { ? '1111111111111' : globalThis.lsh, 13)); - const ascksyhArr = stringToASC(fillZero('1111111111111', 13)) + const ascksyhArr = stringToASC(fillZero(examSubject == 2 ? '0000000000000':'1111111111111', 13)) const ascsbxhArr = stringToASC('00000000') // const ascsbxhArr = stringToASC('153216400880') const serialIndex = globalThis.serialIndex diff --git a/entry/src/main/ets/common/utils/tools.ts b/entry/src/main/ets/common/utils/tools.ts index 962fcc5d..09dbc35c 100644 --- a/entry/src/main/ets/common/utils/tools.ts +++ b/entry/src/main/ets/common/utils/tools.ts @@ -236,4 +236,16 @@ export function convertGpsCoord2 (num){ const du = Math.floor(tempNum / 100); const fen = tempNum % 100 + num - tempNum; return du + fen / 60 -} \ No newline at end of file +} + +export function debounce(fn, delay){ + // 利用闭包定义定时器id变量存储 + let timer = null; + return () => { + // 如果有值就清除定时器,重新计时 + if (timer) { + clearTimeout(timer) + } + timer = setTimeout(fn, delay); + } +}; \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 07c5a93d..b56ff7b0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -28,12 +28,12 @@ export default class EntryAbility extends UIAbility { globalThis.examinerInfo = {} globalThis.deviceNo = ''; globalThis.hasAuth = false - // globalThis.version = '2022.08.13.01'//洛阳 - // globalThis.judgeVersion = '2022.12.05.1' + globalThis.version = '2022.08.13.01'//洛阳 + globalThis.judgeVersion = '2022.12.05.1' // globalThis.judgeVersion = '2022.12.05.1' // globalThis.version = '2022.08.13.01' - globalThis.version = '2024.11.22.14'//济南 - globalThis.judgeVersion = '2024.11.22.14' + // globalThis.version = '2024.11.22.14'//济南 + // globalThis.judgeVersion = '2024.11.22.14' globalThis.videoVersion= '1.0' // globalThis.version = '2023.12.13.01' // globalThis.judgeVersion = '2023.09.30.1' diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index 1ef0283d..a50b8f0f 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -9,6 +9,8 @@ import Judge from './judgeSDK/judge'; import { defaultJudgeConfigObj } from './judgeSDK/utils//judgeCommon'; import {uploadExamMileage} from '../api/judge' import DwztErrorPopup from './compontents/judge/DwztErrorPopup' +import {debounce} from '../common/utils/tools' + import { CARINFO, CDSBInfo, @@ -28,6 +30,7 @@ import { getSyncData } from '../common/service/initable'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import FileUtil from '../common/utils/File'; import SignDisplayCom from './compontents/signDisplayCom'; +import promptAction from '@ohos.promptAction'; @Entry @Component @@ -161,7 +164,8 @@ struct Index { const syssetParams = sysset || await getSyncData('MA_SYSSET') //@ts-ignore const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901'); - this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '123456' + console.info('surenjun serialNumberArr' + JSON.stringify(serialNumberArr)) + this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || ''; const {isTrajectoryOpen} = judgeConfig const syssetJudgeConfigArr = [] @@ -294,13 +298,15 @@ struct Index { this.projectsObj[no2*1] = currentProject this.projectsCenterObj[txt2] = currentProject this.projects.push(currentProject); - console.info('surenjun txt2=>',txt2) //真实监管下发考试项目 if(isInExam && !kStringArr.includes(txt2)){ this.projectsObj[no2*1].type = '3' this.projectsObj[no2*1].isUpload = true this.projectsObj[no2*1].isEnd = true + this.projectsCenterObj[txt2].type = '3' + this.projectsCenterObj[txt2].isUpload = true + this.projectsCenterObj[txt2].isEnd = true this.isDdxk = true this.ddxkKsxmArr.push(txt2) } @@ -382,6 +388,8 @@ struct Index { const projectCode = this.projectsCenterObj[xmdm].projectCode if(this.projectsObj[projectCode]){ this.projectsObj[projectCode].type = '3' + this.projectsObj[projectCode].isUpload = true + this.projectsObj[projectCode].isEnd = true } }) this.ddxkKsxmArr = ddxkKsxmArr @@ -846,10 +854,15 @@ struct Index { this.isDeductedPopShow = false; this.defaultTabIndex = 0; }, - confirmMark: async (itemno, serial) => { - const judge = this.judge - await judge.setJudgeMark(itemno, serial); - this.isDeductedPopShow = false + confirmMark: async (itemno, serial)=>{ + clearTimeout(this.popTimer) + this.popTimer = null + this.popTimer = setTimeout(async ()=>{ + const judge = this.judge + await judge.setJudgeMark(itemno, serial); + this.isDeductedPopShow = false + this.popTimer = null; + },500) } }) } @@ -879,10 +892,15 @@ struct Index { if (this.isAmplifyPopShow && this.examSubject == 3) { AmplifyPopup({ amplifyImgIndex: this.amplifiedImgIndex, - confirmAmplify: async (amplify) => { - const judge = this.judge - await judge.setJudgeItem(amplify.projectCode, 1); - this.isAmplifyPopShow = false + confirmAmplify:async (amplify)=>{ + clearTimeout(this.popTimer) + this.popTimer = null + this.popTimer = setTimeout(async ()=>{ + const judge = this.judge + await judge.setJudgeItem(amplify.projectCode, 1); + this.isAmplifyPopShow = false + this.popTimer = null; + },500) }, closeAmplifyPop: () => { this.isAmplifyPopShow = false @@ -1263,4 +1281,5 @@ struct Index { @State mileageTimer: number = 0; @State passingScore: number = 80 @State dwztErrorVisible: boolean = false; + @State popTimer:number =0; } diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 594f7b5f..8b5daca2 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -651,6 +651,7 @@ struct UserInfo { duration: 4000 }) avPlayer.playAudio(['voice/监管审核未通过.mp3']); + this.isLoadingPopupVisible = false return } this.currentUser.id = '0' @@ -800,7 +801,7 @@ struct UserInfo { drvexam, xtlb: '17', //接口序列号 - jkxlh: this.jkxlh || '', + jkxlh: this.jkxlh, //接口标识 jkid: '17C51', } diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index a92d4f2b..b2bfaffb 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -80,14 +80,16 @@ export default class Judge { this.isExam = !this.judgeUI.singlePlay; const {projectsCenterObj,examSubject} = judgeUI; - //科目三待修改 + (examSubject ==2 ? testKm2Items : testKm3Items ).forEach(item => { + const projectCenterObj = projectsCenterObj[item.code] this.testKmItems[item.code] = item; //考试项目存在 this.testKmItems[item.code] = { code: item.code, - status: 1, - // status: projectsCenterObj[item.code]?.isRequired ? 1 : 0 + status: projectCenterObj === undefined + ? 0 + : ( projectCenterObj.isEnd ? 3 : 1 ) } }) console.info(judgeTag+'testKmItems',JSON.stringify(this.testKmItems)) @@ -156,13 +158,25 @@ export default class Judge { let beginExamInfo = isTrajectoryOpen ? { ...JSON.parse(strArr[1]), replay: 1, - ykxm:judgeConfig.ignoreProjects } : await getJudgeBeginData() await fileLog.setExamJudgeData(beginExamInfo) await examJudgeBeginExam(beginExamInfo); console.info(judgeTag, '6.开始考试注册完成') avPlayer.playAudio([globalThis.singlePlay ? 'voice/ksks.WAV' : 'voice/监管成功.mp3']) + + const {examSubject,projectsObj} = this.judgeUI + if(examSubject == 3){ + //不做模拟灯光,需要做上车准备 =>(请上车准备) + if(projectsObj[41]?.type == 3 && projectsObj[1]?.type != 3){ + avPlayer.playAudio(['voice/上车准备.mp3']) + } + //不做模拟灯光,不做上车准备 =>(请起步,完成考试) + if(projectsObj[41]?.type == 3 && projectsObj[1]?.type == 3){ + avPlayer.playAudio(['voice/402001.mp3']) + } + } + this.judgeUI.draw = true // 处理轨迹plc信息 if (isTrajectoryOpen) { @@ -196,7 +210,7 @@ export default class Judge { h:hxj || 1, }) //@ts-ignore - globalThis.distanceClass.setTimeData(((distance / 100).toFixed(2)) * 1) + globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) } this.prevJd = tJD; this.prevWd = tWD; @@ -628,7 +642,6 @@ export default class Judge { kssj: time } } - console.info(judgeTag +'filePath' , filePath) const {code} = await writeObjectOut(data,filePath) console.info(judgeTag, '项目开始 end') if (code === 2300007) { @@ -970,8 +983,13 @@ export default class Judge { let currentKssycs =0; let voiceURL = '' if (examSubject == 2) { - voiceURL = (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') - switch (voiceURL){ + if (isAllProjectsEnd) { + voiceURL = (totalScore < passingScore ? `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` : 'voice/qualified.mp3') + }else{ + voiceURL = `voice/unqualified_${kssycs == 1 ? 'one' : 'two'}.wav` + currentKssycs = kssycs == 1 ? 0 : 1 + } + switch (voiceURL){ case 'voice/unqualified_one.wav': currentKssycs = 0; break; @@ -1069,6 +1087,7 @@ export default class Judge { const projectsObj = this.judgeUI.projectsObj return projectsObj[type]?.abbreviation || '通用评判' } + // 扣分项目转换 getKfStr = (code) => { const markRuleListObj = this.judgeUI.markRuleListObj; @@ -1113,7 +1132,7 @@ export default class Judge { const sbxh = getSbxh(xmdm, xmxh) const {carzt,dcjl,qjjl,dxjl,bxjl} = performInfo || {}; const asclshArr = stringToASC( - fillZero((singlePlay ? 1111111111111 : lsh) || 0, 13) + fillZero((singlePlay ? (examSubject == 2 ? '0000000000000':'1111111111111') : lsh) || 0, 13) ); //13不足要补0 const ascksyhArr = stringToASC(fillZero(ksyh || 0, 13)) @@ -1130,7 +1149,6 @@ export default class Judge { //@ts-ignore let tempSd = ((judgeConfigObj['350'] ==0 ? sd : cs) * 1.852).toFixed(0) * 1 - console.info(judgeTag + "prevSD",tempSd); if(tempSd < 1){ tempSd = 0 } @@ -1234,7 +1252,6 @@ export default class Judge { status: getCenterProjectStatus(current.status) } }) - // console.info(judgeTag+'TranslateProject',JSON.stringify(tempItems)); const arr = []; for (let i = 0; i <= 4; i++) { @@ -1282,6 +1299,7 @@ export default class Judge { } //人工操作项目 public setJudgeItem = async (itemno, type: 1 | 2) => { + console.info('surenjun','2') const {fileLog} = this; await examJudgeArtificialItem(itemno * 1, type); await fileLog.setExamJudgeData({ @@ -1398,7 +1416,10 @@ export default class Judge { if (udpIndex % 5 === 0 && !isUdpEnd) { const judgeUdp = globalThis.judgeUdp const bytes = await this.getMessageHeartbeat(isExamEnd); + console.info(judgeTag,JSON.stringify(bytes)) + console.info(judgeTag,'udp-prev-send') judgeUdp.send(bytes) + console.info(judgeTag,'udp-prev-end') } globalThis.udpIndex += 1 } @@ -1450,12 +1471,13 @@ export default class Judge { const msgStr = strArr[num]; if(msgStr == ''){ console.info(judgeTag, '模拟数据考试结束') - // globalThis.windowClass.setWindowSystemBarEnable(['navigation']) + globalThis.windowClass.setWindowSystemBarEnable(['navigation']) clearInterval(judgeTimer) this.checkExamIsEnd(true) return } const msg = JSON.parse(strArr[num]); + num++ // 4.过程数据 this.tempData = msg this.judgeUI.isDwztRight = msg?.gps?.dwzt == 4; @@ -1473,8 +1495,8 @@ export default class Judge { await examJudgeRealExam(msg) const bytes = await this.getMessageHeartbeat(); bytes && globalThis.judgeUdp.send(bytes) - num++ - }, 200) + + }, 50) globalThis.judgeTimer = judgeTimer; } diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts index 81dd9a3f..5ab18a99 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts @@ -16,7 +16,7 @@ export const judgeConfig = { // 本地模型地址 modelPath: 'models/model_enc', // 济南科目三 - trajectoryPath: 'logs/2024_08_17/2024_08_17_16_51_24_9999282315477_203908531884520064_彭雯季/judge_exam_data.txt', + trajectoryPath: 'logs/2024_08_29/2024_08_29_09_48_08_2230612098578_410311200501058031_闫嘉衡/judge_exam_data.txt', //四合一画面配置 fourInOneScreen:{ //gps位数