diff --git a/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts b/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts index 61c0fee0..7631f375 100644 --- a/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts +++ b/entry/src/main/ets/IdlServiceExt/idl_service_ext_impl.ts @@ -33,6 +33,12 @@ export default class ServiceExtImpl extends IdlServiceExtStub { console.log("lixiao error", JSON.stringify(err)) }) }).catch(err => { + callback(0, JSON.stringify({ + code: 1, + data: { + code: 2300007 + } + })); console.log("lixiao paste error", JSON.stringify(err)) }) } diff --git a/entry/src/main/ets/common/service/logService.ts b/entry/src/main/ets/common/service/logService.ts new file mode 100644 index 00000000..84ac1515 --- /dev/null +++ b/entry/src/main/ets/common/service/logService.ts @@ -0,0 +1,22 @@ +import fs from '@ohos.file.fs'; + + +export function delLog(offset: number) { + try { + const path = "/mnt/hmdfs/100/account/device_view/local/files/duolun/logs" + const list = fs.listFileSync(path) + const now = new Date().getTime() + list.forEach(filename => { + const year = Number(filename.split("_")[0]) + const month = Number(filename.split("_")[1]) - 1 + const date = Number(filename.split("_")[2]) + const fileDate = new Date(year, month, date).getTime() + if (now - fileDate >= offset * 24 * 60 * 60 * 1000) { + fs.rmdirSync(path + "/" + filename) + console.log("lixiao delete log success path: ", path + "/" + filename) + } + }) + } catch (e) { + console.log("lixiao delete log error", JSON.stringify(e)) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/GlobalUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts index ba599236..74c1f5ff 100644 --- a/entry/src/main/ets/common/utils/GlobalUdp.ts +++ b/entry/src/main/ets/common/utils/GlobalUdp.ts @@ -4,25 +4,25 @@ import { getSyncData } from '../service/initable' import { getChuankouFn } from '../../common/service/indexService' import FileUtil from '../../common/utils/File' import { GlobalConfig } from '../../config/index' -import {Array2Byte,fillZero,string2Bytes}from './tools' +import { Array2Byte, fillZero, string2Bytes } from './tools' import emitter from '@ohos.events.emitter'; export async function sendMsg(val) { // globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val) } -export async function getUDP(context,errorFlag?) { - return new Promise(async (reslove,reject)=>{ +export async function getUDP(context, errorFlag?) { + return new Promise(async (reslove, reject) => { const fileUtil = new FileUtil(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); - console.log('ttttt',data) + console.log('ttttt', data) if (data === '' || data === undefined) { console.log(` getUDP has no IPConfigTable `); globalThis.udpClient = {} globalThis.host = '' reslove('') } else { - const result=JSON.parse(data) + const result = JSON.parse(data) console.log(` getUDP has IPConfigTable `); if (globalThis.udpClient && globalThis.udpClient.closeUdp) { console.log(` getUDP has udclent close and rebind `); @@ -31,11 +31,11 @@ export async function getUDP(context,errorFlag?) { globalThis.udpClient.rebindUdp(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort) globalThis.udpClient.sendMsg('111', null) globalThis.host = `http://${result.centerIp}:${result.centerPort}` - globalThis.udpClient.onError_Callback(()=>{ + globalThis.udpClient.onError_Callback(() => { console.log('getUDPgetUDPgetUDP') - getUDP(context,true) - if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){ - globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1 + getUDP(context, true) + if (errorFlag && globalThis.udpClient && globalThis.udpClient.onMessage_1) { + globalThis.udpClient.onMessage_1 = globalThis.udpClient.onMessage_1 } }) reslove(`http://${result.centerIp}:${result.centerPort}`) @@ -48,21 +48,21 @@ export async function getUDP(context,errorFlag?) { else { // 未绑定 console.log(` getUDP has no udclent and bind `); - console.log('ttttttdata',JSON.stringify(result)) + console.log('ttttttdata', JSON.stringify(result)) const udpClient: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort) udpClient.bindUdp() udpClient.sendMsg('111') globalThis.host = `http://${result.centerIp}:${result.centerPort}` globalThis.udpClient = udpClient - globalThis.udpClient.onMessage_1(()=>{ + globalThis.udpClient.onMessage_1(() => { console.log('getUDPonMessage_1msgmsgByGloalUdp') }) - globalThis.udpClient.onError_Callback(()=>{ - getUDP(context,true) - if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){ - globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1 + globalThis.udpClient.onError_Callback(() => { + getUDP(context, true) + if (errorFlag && globalThis.udpClient && globalThis.udpClient.onMessage_1) { + globalThis.udpClient.onMessage_1 = globalThis.udpClient.onMessage_1 } }) getChuankouFn() @@ -82,11 +82,11 @@ export async function getUDP(context,errorFlag?) { globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort) globalThis.udpClient.sendMsg('111', null) globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}` - globalThis.udpClient.onError_Callback(()=>{ + globalThis.udpClient.onError_Callback(() => { console.log('getUDPgetUDPgetUDP') - getUDP(true,context) - if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){ - globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1 + getUDP(true, context) + if (errorFlag && globalThis.udpClient && globalThis.udpClient.onMessage_1) { + globalThis.udpClient.onMessage_1 = globalThis.udpClient.onMessage_1 } }) reslove(`http://${result[0].centerIp}:${result[0].centerPort}`) @@ -105,14 +105,14 @@ export async function getUDP(context,errorFlag?) { globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}` globalThis.udpClient = udpClient - globalThis.udpClient.onMessage_1(()=>{ + globalThis.udpClient.onMessage_1(() => { console.log('getUDPonMessage_1msgmsgByGloalUdp') }) - globalThis.udpClient.onError_Callback(()=>{ - getUDP(true,context) - if(errorFlag&&globalThis.udpClient&&globalThis.udpClient.onMessage_1){ - globalThis.udpClient.onMessage_1=globalThis.udpClient.onMessage_1 + globalThis.udpClient.onError_Callback(() => { + getUDP(true, context) + if (errorFlag && globalThis.udpClient && globalThis.udpClient.onMessage_1) { + globalThis.udpClient.onMessage_1 = globalThis.udpClient.onMessage_1 } }) // udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{}) @@ -140,25 +140,25 @@ export async function getUDP(context,errorFlag?) { } -export async function getUDP2(context,errorFlag?) { +export async function getUDP2(context, errorFlag?) { const fileUtil = new FileUtil(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); if (data === '' || data === undefined) { globalThis.udpClient2 = {} globalThis.udpClient2.setMsgCallBack = () => { } - }else{ - const result=JSON.parse(data) + } else { + const result = JSON.parse(data) console.log(` getUDP2 has IPConfigTable `); if (globalThis.udpClient2 && globalThis.udpClient2.closeUdp) { console.log(` getUDP2 has udclent ,close and rebind `); globalThis.udpClient2.closeUdp(async () => { setTimeout(() => { globalThis.udpClient2.rebindUdp(result.udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort) - globalThis.udpClient2.onError_Callback(()=>{ - getUDP2(context,true); - if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){ - globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2 + globalThis.udpClient2.onError_Callback(() => { + getUDP2(context, true); + if (errorFlag && globalThis.udpClient2 && globalThis.udpClient2.onMessage_2) { + globalThis.udpClient2.onMessage_2 = globalThis.udpClient2.onMessage_2 } }) }, 1000) @@ -170,31 +170,32 @@ export async function getUDP2(context,errorFlag?) { const udpClient2: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort) console.info('surenjun udp2=> ', globalThis.carInfo?.messagePort) await udpClient2.bindUdp() - await udpClient2.onError_Callback(()=>{ - getUDP2(context,true); - if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){ - globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2 + await udpClient2.onError_Callback(() => { + getUDP2(context, true); + if (errorFlag && globalThis.udpClient2 && globalThis.udpClient2.onMessage_2) { + globalThis.udpClient2.onMessage_2 = globalThis.udpClient2.onMessage_2 } }) - if(!errorFlag){ + if (!errorFlag) { await udpClient2.onMessage_2((val) => { if (val.id == '32') { globalThis.signNum = val.body[1] - if(val.body[0] == 5){ + if (val.body[0] == 5) { console.info('surenjun', `接收到平台扣分请求,请求指令为:${val.body[1]}`) globalThis.udpEvent.sendOnKf(val.body[1]) } - if(val.body[0] == 11){ - console.info('surenjun','GlobalUdp收到beginExam事件') + if (val.body[0] == 11) { + console.info('surenjun', 'GlobalUdp收到beginExam事件') globalThis.udpEvent.sendBeginExam(val.body[1]) } - if(val.body[0] == 12){ - console.info('surenjun','GlobalUdp收到endExam事件') + if (val.body[0] == 12) { + console.info('surenjun', 'GlobalUdp收到endExam事件') globalThis.udpEvent.sendEndExam(val.body[1]) } - }if (val.id == '36'){ + } + if (val.id == '36') { //获取远程扣分内容 - console.info('surenjun','考车收到远程扣分项目内容,扣分代码:' + val.body[0]) + console.info('surenjun', '考车收到远程扣分项目内容,扣分代码:' + val.body[0]) globalThis.udpEvent.sendKfContent(val.body[0]) } else if (val.id == '46') { let tmpList = [] @@ -226,10 +227,10 @@ export async function getUDP2(context,errorFlag?) { globalThis.udpClient2.closeUdp(async () => { setTimeout(() => { globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort) - globalThis.udpClient2.onError_Callback(()=>{ + globalThis.udpClient2.onError_Callback(() => { getUDP2(true); - if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){ - globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2 + if (errorFlag && globalThis.udpClient2 && globalThis.udpClient2.onMessage_2) { + globalThis.udpClient2.onMessage_2 = globalThis.udpClient2.onMessage_2 } }) }, 1000) @@ -240,13 +241,13 @@ export async function getUDP2(context,errorFlag?) { console.log(` getUDP2 has no udclent and bind `); const udpClient2: UdpClientByCenter = new UdpClientByCenter(result[0].udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort) await udpClient2.bindUdp() - await udpClient2.onError_Callback(()=>{ + await udpClient2.onError_Callback(() => { getUDP2(true); - if(errorFlag&&globalThis.udpClient2&&globalThis.udpClient2.onMessage_2){ - globalThis.udpClient2.onMessage_2=globalThis.udpClient2.onMessage_2 + if (errorFlag && globalThis.udpClient2 && globalThis.udpClient2.onMessage_2) { + globalThis.udpClient2.onMessage_2 = globalThis.udpClient2.onMessage_2 } }) - if(!errorFlag){ + if (!errorFlag) { await udpClient2.onMessage_2((val) => { if (val.id == '32') { globalThis.signNum = val.body[1] @@ -320,11 +321,13 @@ export async function setJudgeUdp() { globalThis.carInfo?.udpAddress, globalThis.carInfo?.hintPort ) - console.info('surenjun hintPort=> ',globalThis.carInfo?.hintPort) + console.info('surenjun hintPort=> ', globalThis.carInfo?.hintPort) - await udpClientbyCenter.onError_Callback(()=>{}) + await udpClientbyCenter.onError_Callback(() => { + }) await udpClientbyCenter.bindUdp() - await udpClientbyCenter.onMessage_2((val) => {}) + await udpClientbyCenter.onMessage_2((val) => { + }) //远程监听开始考试、结束考试、扣分指令 @@ -343,7 +346,7 @@ export async function setJudgeUdp() { }, //申请远程扣分查询 - askKf(directives){ + askKf(directives) { globalThis.udpClient2.sendMsgExt({ id: 35, list: [directives], @@ -354,17 +357,27 @@ export async function setJudgeUdp() { }, //确定远程扣分 - confirmKf(directives,code){ + confirmKf(directives, code) { globalThis.udpClient2.sendMsgExt({ id: 37, - list: Array2Byte([string2Bytes(directives,8),string2Bytes(code,8)]), + list: Array2Byte([string2Bytes(directives, 8), string2Bytes(code, 8)]), carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId }) console.info('surenjun', `考车发送确定扣分指令,指令为:${directives}`) }, + //申请语音对讲 + askVoice() { + globalThis.udpClient2.sendMsgExt({ + id: 49, + list: [], + carNo: globalThis.carInfo.carNo, + placeId: globalThis.carInfo.examinationRoomId, + }) + } } } } + // globalThis.udpClient.bindUdp() diff --git a/entry/src/main/ets/common/utils/UdpJudge.ts b/entry/src/main/ets/common/utils/UdpJudge.ts index 1a287d58..b9331240 100644 --- a/entry/src/main/ets/common/utils/UdpJudge.ts +++ b/entry/src/main/ets/common/utils/UdpJudge.ts @@ -60,8 +60,8 @@ export const getMessageHeartbeat = async (msg) => { const {fourInOneScreen:{gpsDigit}} = judgeConfig const asclshArr = stringToASC(fillZero( globalThis.singlePlay - ? '1111111111111' - : globalThis.lsh, + ? (examSubject == 2 ? '0000000000000' : '0000000000000') + : (globalThis.lsh || '0000000000000'), 13)); const ascksyhArr = stringToASC(fillZero(examSubject == 2 ? '0000000000000':'1111111111111', 13)) const ascsbxhArr = stringToASC('00000000') diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 642d3942..010d14cc 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -8,7 +8,7 @@ import { TempLogger } from '../common/utils/TempLogger'; import DB from '../common/database/DbSql'; import { initTable } from '../common/service/initable'; import Want from '@ohos.app.ability.Want'; -import { examPeerOccupy } from '../pages/judgeSDK/api'; +import { examJudgeVersion, examPeerOccupy } from '../pages/judgeSDK/api'; export default class EntryAbility extends UIAbility { async onCreate(want, launchParam) { @@ -52,8 +52,6 @@ export default class EntryAbility extends UIAbility { globalThis.deviceNo = ''; globalThis.hasAuth = false - // globalThis.judgeVersion ='2024.08.24.1' - // globalThis.version ='2023.12.13.01'; globalThis.version = GlobalConfig.version.jn.km3[0]; globalThis.judgeVersion = GlobalConfig.version.jn.km3[1]; globalThis.tcpSendNum = 0 @@ -76,9 +74,6 @@ export default class EntryAbility extends UIAbility { console.info('jiangsong globalThis.pathDir = ' + globalThis.pathDir); // this.requestPermission(this.context) // this.featureAbilityAuth() - TempLogger.init() - // tcp创建连接 - // await tcpUtil.init() const windowClass = await windowStage.getMainWindow(); globalThis.windowClass = windowClass diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 2c1eef19..b3de3206 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -22,12 +22,13 @@ import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import IdlServiceExtProxy from '../IdlServiceExt/idl_service_ext_proxy'; import Want from '@ohos.app.ability.Want'; import emitter from '@ohos.events.emitter'; +import { examJudgeVersion } from './judgeSDK/api'; +import { delLog } from '../common/service/logService'; @Entry @Component struct Index { @State carNum: string = '' - @State version: string = '' @State url: string = '' @State hasAuth: boolean = false; @State dialogVisiable: boolean = false; @@ -58,6 +59,8 @@ struct Index { private avPlayer private context = getContext(this) as common.UIAbilityContext; private serviceExtProxy: IdlServiceExtProxy + @State judgeVersion: string = "" + private version: string = "2025.04.21.01" @Styles commStyle(){ @@ -194,12 +197,12 @@ struct Index { Column() { Row() { Column() { - Text('V外壳:' + globalThis.version) + Text('V外壳:' + this.version) .fontColor('#CCAE7A') .fontSize(18 * globalThis.ratio) .width('30%') .margin({ bottom: 10 }) - Text('V评判:' + globalThis.judgeVersion) + Text('V评判:' + this.judgeVersion) .fontColor('#CCAE7A') .fontSize(18 * globalThis.ratio) .width('30%') @@ -443,6 +446,7 @@ struct Index { // globalThis.param854Str=sys.v_value delPic(Number(sys.v_value), 1) delPic(Number(sys.v_value), 2) + delLog(Number(sys.v_value)) // this.delLoading=false } @@ -611,6 +615,7 @@ struct Index { } async initParams() { + this.judgeVersion = await examJudgeVersion() await getUDP(this.context, false) this.loading = false await getDeviceInfo(this.context) @@ -626,7 +631,6 @@ struct Index { console.info('surenjun', 'distanceClass=>初始化完成') } this.carNum = globalThis.carInfo.plateNo; - this.version = globalThis.version; this.hasAuth = globalThis.hasAuth; setTimeout(() => { this.initParamFlag = true diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index c4fd91cf..8407daa0 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -111,6 +111,7 @@ struct Index { FLAG: carInfo.flag, BK1: carInfo.bk1, BK2: carInfo.bk2, + X_MCH: carInfo.x_mch, }) console.info('surenjun =>carinfoArrr',JSON.stringify( this.carinfoArr)) } diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index b2bbee21..9515c312 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -140,7 +140,9 @@ struct UserInfo { // 同一学员连续第二次考试时不再验证身份 if (this.currentUser.kssycs == '1' && this.systemParam.Param830Str == '1') { this.sfbdinterfaceFn() + } else { + this.ksksLimit = false this.showFaceCompare = true } } else { @@ -148,6 +150,7 @@ struct UserInfo { } } catch (e) { console.info('Throw Error', JSON.stringify(e)) + this.ksksLimit = false } } @@ -881,6 +884,7 @@ struct UserInfo { //身份比对 async sfbdinterfaceFn() { + this.ksksLimit = false globalThis.statue = 4 this.stepFlag = true const carInfo = globalThis.carInfo; @@ -894,7 +898,7 @@ struct UserInfo { carId, lsh: this.currentUser.lsh || '', examinationRoomId - }); + }) } this.currentUser.id = '1' const avPlayer = this.avPlayer; diff --git a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts index f398950e..bf46e8ef 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/judgeSDK.d.ts @@ -73,6 +73,7 @@ export interface CARINFO { FLAG: string, BK1: string, BK2: string + X_MCH: string } export interface MAPPOINT { diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index 364d4f0c..62272687 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -696,13 +696,13 @@ export default class Judge { if (this.disConnectNum < 5 && this.disConnectNum > 0) { console.log("wzj", "第" + this.disConnectNum + "次重新发送", JSON.stringify(data)) } - //断网&网络超时次数计算 - if (temp.code == 2300007 || temp.code == 2300028) { + if ( + //后台连接中心异常 + temp.code == -1 || temp.code == 0 || + //断网&网络超时次数计算 + temp.code == 2300007 || temp.code == 2300028) { this.disConnectNum += 1; if (this.disConnectNum < 5) { - if (temp.code == 2300028) { - await new Promise(resolve => setTimeout(resolve, 1000)); // 延迟1秒 - } return await this.sendWriteObjectOut(data, filePath) } }