diff --git a/entry/src/main/ets/api/index.ts b/entry/src/main/ets/api/index.ts index d2351940..12b7bea7 100644 --- a/entry/src/main/ets/api/index.ts +++ b/entry/src/main/ets/api/index.ts @@ -51,12 +51,13 @@ export async function initCenterCache(params,url){ }) } //参数下发读表接口 -export async function initCenterCacheByKSPT(params){ +export async function initCenterCacheByKSPT(params,url){ return await request({ url:'/der2/services/para/initCenterCache.ws', data:params, method:'post', xml:false, + host:url }) } @@ -77,6 +78,7 @@ export async function initialization(params){ url:'/der2/services/exam/initialization.ws', data:`${params.carId}${params.examinationRoomId}${params.shellVersion}${params.judgeVersion}${params.videoVersion}`, method:'post', + host:params.host, xml:true, }) } diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 35ec2823..b91c11bd 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -148,7 +148,7 @@ export async function getDataBaseTable(params,reqParam) { "typeRsp": "0" // 赋默认值0,无需改变 } } - let res: any = await initCenterCache(str) + let res: any = await initCenterCache(str,reqParam.centerHost) if( res.body[params.tableName].length==0){ resolve(); return @@ -248,7 +248,7 @@ export async function getMySystemSetTable(params,reqParam) { "typeRsp": "0" // 赋默认值0,无需改变 } } - initCenterCacheByKSPT(str).then((res)=>{ + initCenterCacheByKSPT(str,reqParam.url).then((res)=>{ if( res.body[params.tableName].length==0){ resolve(); return @@ -357,9 +357,10 @@ export async function upDataZhongxinginitialization(param){ "examinationRoomId": param.examinationRoomId, //考试平台kdid videoVersion:'1.0', judgeVersion:param.judgeVersion, - shellVersion: param.shellVersion + shellVersion: param.shellVersion, + host:param.host } - console.log('daihai2') + console.log('daihai2',JSON.stringify(str)) initialization(str).then(async (res)=>{ console.log('daihai3',JSON.stringify(res)) diff --git a/entry/src/main/ets/common/utils/GlobalUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts index 9b22ebca..22643cfb 100644 --- a/entry/src/main/ets/common/utils/GlobalUdp.ts +++ b/entry/src/main/ets/common/utils/GlobalUdp.ts @@ -19,7 +19,7 @@ export async function getUDP() { 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_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{}) + // globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{}) }, 1000) }) } @@ -43,7 +43,7 @@ export async function getUDP() { // globalThis.udpClient.closeUdp(async ()=>{ }) // } globalThis.udpClient = {} - globalThis.udpClient.onMessage_1 = () => {} + // globalThis.udpClient.onMessage_1 = () => {} globalThis.host = '' } }) @@ -66,10 +66,9 @@ export async function getUDP2() { // 未绑定 console.log(` getUDP2 has no udclent and bind `); const udpClient2: UdpClientByCenter = new UdpClientByCenter(result[0].udplocalIp, '8800', globalThis.carInfo?.udpAddress, globalThis.carInfo?.messagePort) - - udpClient2.bindUdp() - udpClient2.onError_Callback() - udpClient2.onMessage_2((val) => { + await udpClient2.bindUdp() + await udpClient2.onError_Callback() + await udpClient2.onMessage_2((val) => { if (val.id == '32') { globalThis.signNum = val.body[1] @@ -92,8 +91,6 @@ export async function getUDP2() { } } else { globalThis.udpClient2 = {} - globalThis.udpClient2.onMessage_2 = () => { - } globalThis.udpClient2.setMsgCallBack = () => { } } @@ -130,8 +127,8 @@ export async function setJudgeUdp() { if (config && config[0] && config[0].udplocalIp) { const {udplocalIp} = config[0]; const udpClientbyCenter: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080', globalThis.carInfo?.gpsAddress, globalThis.carInfo?.hintPort) - udpClientbyCenter.bindUdp() - udpClientbyCenter.onMessage_1((val) => { + await udpClientbyCenter.bindUdp() + await udpClientbyCenter.onMessage_1((val) => { console.log('valval', val) }) // globalThis.judgeUdpClient = udpClientbyCenter; diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index d72b6294..4e6d27bc 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -242,18 +242,14 @@ export default class UdpClientByCenter { closeUdp(callback?) { console.log('UdpClientByCenter enter closeUdp ip:' + this.localIp + ' port:' + this.localIpPort); - this.udp.on('close', () => { - console.log('UdpClientByCenter onClose ip:' + this.localIp + ' port:' + this.localIpPort); - this.isWorking = false - if (callback != null) { - callback() - } - } - ) this.udp.close(err => { if (err) { console.log('UdpClientByCenter closeUdp failed ip:' + this.localIp + ' port:' + this.localIpPort + ' err:' + JSON.stringify(err)); } else { + this.isWorking = false + if (callback != null) { + callback() + } console.log('UdpClientByCenter closeUdp succeed ip:' + this.localIp + ' port:' + this.localIpPort); } }) @@ -261,7 +257,7 @@ export default class UdpClientByCenter { //plc onMessage_1(callback?) { - this.udp.on('message', value => { + this.udp&&this.udp.on('message', value => { console.log(TAG, 'udponmessage') // 收到的是ArrayBuffer 需要进行转换解析 this.plcUdpError = false diff --git a/entry/src/main/ets/common/utils/request.ts b/entry/src/main/ets/common/utils/request.ts index 993343db..917ecfcb 100644 --- a/entry/src/main/ets/common/utils/request.ts +++ b/entry/src/main/ets/common/utils/request.ts @@ -35,7 +35,7 @@ export default async function request(req: any) { paramsStr = paramsStr.toString(); paramsStr = paramsStr.substring(0, paramsStr.length-1) try { - let baseUrl=host?host:(globalThis.host||GlobalConfig.host) + let baseUrl=host?host:globalThis.host // let baseUrl=host?config.csptHost:config.host' console.info('surenjun',baseUrl) diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index ea4f9da0..07c6b125 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -42,7 +42,6 @@ export default class EntryAbility extends UIAbility { spzd3:false, spzd4:false, } - globalThis.singlePlay=false //单机模式 globalThis.signNum=0//心跳指令编号 globalThis.lsh='0000000000000'//学员流水号 globalThis.ratio= 1700 / 960 //适配比例 diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 41b8eda3..ee0a64cb 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -15,6 +15,7 @@ import { getliushuiNum, setliushuiNum } from '../common/service/indexService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' +import { voiceService } from '../common/service/voiceService'; @Entry @Component @@ -33,6 +34,7 @@ struct Index { fileHelper = null; private fileUtil: FileUtil private interval = null; + private vocObj = null; private workerInstance = null; private context = getContext(this) as common.UIAbilityContext; @@ -213,6 +215,8 @@ struct Index { globalThis.ratio = 1700 / 960 this.angle = 0 this.loading = false + this.vocObj = new voiceService(async (status, val, next) => { + }); } async testXMLToJSONInWorker() { @@ -224,7 +228,9 @@ struct Index { shellVersion: globalThis.version, paraKdid: globalThis.timeInfo?.paraKdid, mode: globalThis.timeInfo?.mode, - context: this.context + context: this.context, + host:globalThis.host, + centerHost:globalThis.timeInfo.url } workerInstance.postMessage(param); workerInstance.onmessage = (e: MessageEvents): void => { @@ -287,6 +293,10 @@ struct Index { // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { + this.vocObj.playAudio({ + type: 1, + name: 'welcome.wav' + }) globalThis.singlePlay = false } this.isSingle = globalThis.singlePlay diff --git a/entry/src/main/ets/pages/VideoConfig.ets b/entry/src/main/ets/pages/VideoConfig.ets index 325f4cd9..a64d4abb 100644 --- a/entry/src/main/ets/pages/VideoConfig.ets +++ b/entry/src/main/ets/pages/VideoConfig.ets @@ -555,6 +555,7 @@ struct Index { } aboutToAppear() { + this.ratio=globalThis.ratio this.openFlag = true const fileUtil = new FileUtil(this.context) this.fileUtil = fileUtil diff --git a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets index eaf03065..614af9ad 100644 --- a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets +++ b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets @@ -308,6 +308,7 @@ export default struct SignDisplayCom { if (showBack) { + this.ratio=1.4 globalThis.udpClient.onMessage_1((msg) => { console.log('msgmsg', msg) if (msg) { diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index b83f3bb1..72245448 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -1,3 +1,5 @@ + + { "module": { "name": "entry", @@ -36,6 +38,7 @@ ], "requestPermissions":[ {"name": "ohos.permission.CONNECTIVITY_INTERNAL"}, + {"name": "ohos.permission.SET_TIME"}, { "name": "ohos.permission.INTERNET" }, diff --git a/entry/src/main/resources/rawfile/welcome.wav b/entry/src/main/resources/rawfile/welcome.wav new file mode 100644 index 00000000..38f42721 Binary files /dev/null and b/entry/src/main/resources/rawfile/welcome.wav differ