From 3e53801f1219e5471c9f75b69c385e9965beb6c6 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Mon, 12 Aug 2024 14:46:16 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/service/initable.ts | 29 ++++++++++++- entry/src/main/ets/pages/Index.ets | 42 +++++++++++-------- entry/src/main/ets/pages/TerminalInfos.ets | 2 +- entry/src/main/ets/pages/UserInfo.ets | 16 ++++--- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 20a9016c..571d620f 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -26,6 +26,8 @@ import DeviceInfoTable from '../constants/DeviceInfoTable'; import USER from '../constants/USER'; import util from '@ohos.util'; import FileModel from '../../pages/judgeSDK/utils/fileModel'; +import FileUtil from '../../common/utils/File'; +import { GlobalConfig } from '../../config/index'; // @ts-nocheck //读表 @@ -330,6 +332,27 @@ export async function upDataZhongxinginitialization(param) { resolve(false) return } + if(param.singlePlay){ + const fileUtil = new FileUtil(param.context) + const tableList=['MA_ITEMINFO','MA_MARKRULE','MA_SYSTEMPARM','MA_MAP_COLLECT','MA_MAP_COLLECT_SHAPE','MA_MAP_ITEMCLASS','MA_MAP_POINT','MA_MAP_POINT_ITEM','MA_MAP_ROAD','MA_MAP_ROAD_LANE','MAP_SUBITEM','MA_SYSSET','ES_CARINFO','MA_MARKRULESET','MA_CDSBINFO','MA_T_CARPARMSET']; + tableList.map(async(tableName)=>{ + const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableName}.txt`); + if(data&&JSON.parse(data)&&JSON.parse(data).length>0){ + sqlInsertCommonFn(tableName, JSON.parse(data), param.context).then((result) => { + console.log(key, '单机表建立成功') + if (result) { + resolve(true) + } else { + resolve(false) + } + }).catch((msg) => { + reject(false) + console.log(key, '单机表建立失败') + }) + } + }) + return + } const str = { "carId": param.carId, // 表名 "examinationRoomId": param.examinationRoomId, //考试平台kdid @@ -370,7 +393,7 @@ export async function upDataZhongxinginitialization(param) { } function setSyncCenterSqlData(key, res, param) { - return new Promise((resolve, reject) => { + return new Promise(async(resolve, reject) => { const mapName = { 'ItemInfo': 'MA_ITEMINFO', 'MarkRule': 'MA_MARKRULE', @@ -389,7 +412,6 @@ function setSyncCenterSqlData(key, res, param) { 'MarkRuleSet': 'MA_MARKRULESET', 'Cdsbinfo': 'MA_CDSBINFO', 'T_CarParmSet': 'MA_T_CARPARMSET', - // 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER } // const accountTable = new AccountTable(() => { // }, centerToMap[key],param.context); @@ -399,6 +421,9 @@ function setSyncCenterSqlData(key, res, param) { } else { arrList = [res.initializationRsp.body[key].record] } + const fileUtil = new FileUtil(param.context) + const folderPath = await fileUtil.initFolder(`/config/tableList`); + fileUtil.addFile(`${folderPath}/${mapName[key]}.txt`, JSON.stringify(arrList)) console.log('mapName[key]', mapName[key], key) sqlInsertCommonFn(mapName[key], arrList, param.context).then((result) => { console.log(key, '表建立成功') diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 0a555f1f..6bf37220 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,5 +1,4 @@ // @ts-nocheck -import { VideoConfig } from './interfaces' import common from '@ohos.app.ability.common'; import router from '@ohos.router'; import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'; @@ -16,7 +15,7 @@ import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' import { voiceService } from '../common/service/voiceService'; - +// import errorMsgDialog from './compontents/errorMsgDialog' @Entry @Component struct Index { @@ -48,7 +47,11 @@ struct Index { .backgroundImageSize({ width: '100%', height: '100%' }) .margin({ bottom: 12 * this.ratio}) } - + // dialogController: CustomDialogController | null = new CustomDialogController({ + // builder: errorMsgDialog({ + // cancel: ()=> { this.onCancel() }, + // confirm: ()=> { this.onAccept() } + // }) build() { Column() { Column() { @@ -100,7 +103,7 @@ struct Index { Column() { Row() { if (!this.isSingle) { - Image($r('app.media.index_lw')).width('28%').height('71%').margin({left:10 * globalThis.ratio}).onClick(async () => { + Image($r('app.media.index_lw')).width('28%').height('71%').margin({left:80 * globalThis.ratio}).onClick(async () => { if (this.loading) { return } @@ -123,7 +126,7 @@ struct Index { }) } if (this.isSingle) { - Image($r('app.media.index_dj')).width('30.5%').height('74%').margin({left:10 * globalThis.ratio}).onClick(() => { + Image($r('app.media.index_dj')).width('28%').height('71%').margin({left:80 * globalThis.ratio}).onClick(() => { if (this.loading) { return } @@ -133,7 +136,7 @@ struct Index { }, router.RouterMode.Single); }) } - Image($r('app.media.index_zj')).width('28%').height('71%').margin({right:10* globalThis.ratio}).onClick(() => { + Image($r('app.media.index_zj')).width('28%').height('71%').margin({right:80* globalThis.ratio}).onClick(() => { if (this.loading) { return } @@ -257,8 +260,7 @@ struct Index { this.dialogVisiable=false this.angle = 0 this.loading = false - this.vocObj = new voiceService(async (status, val, next) => { - }); + } async testXMLToJSONInWorker() { @@ -272,7 +274,8 @@ struct Index { mode: globalThis.timeInfo?.mode, context: this.context, host:globalThis.host, - centerHost:globalThis.timeInfo.url + centerHost:globalThis.timeInfo.url, + singlePlay:globalThis.singlePlay } workerInstance.postMessage(param); workerInstance.onmessage = (e: MessageEvents): void => { @@ -313,6 +316,18 @@ struct Index { } async onPageShow() { + this.vocObj = new voiceService(async (status, val, next) => { + }); + + console.log('globalThis.singlePlay',globalThis.singlePlay) + if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { + this.vocObj.playAudio({ + type: 1, + name: 'welcome.wav' + }) + globalThis.singlePlay = false + } + this.isSingle = globalThis.singlePlay this.loading = false this.userAuth(); this.createAlbum() @@ -333,15 +348,6 @@ struct Index { getTCP() // 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 - console.info('Index onPageShow'); } diff --git a/entry/src/main/ets/pages/TerminalInfos.ets b/entry/src/main/ets/pages/TerminalInfos.ets index b8a73366..a805856a 100644 --- a/entry/src/main/ets/pages/TerminalInfos.ets +++ b/entry/src/main/ets/pages/TerminalInfos.ets @@ -83,7 +83,7 @@ struct Index { const fileUtil = new FileUtil(this.context) const folderPath = await fileUtil.initFolder(`/config`); const param={udplocalIp:this.inputTextList1[9],udplocalIpPort:this.inputTextList1[10],udpOppositeIp:this.inputTextList1[7],udpOppositeIpPort:this.inputTextList1[8],tcplocalIp:this.inputTextList1[9],tcplocalIpPort:'8088',tcpOppositeIp:this.inputTextList1[0],tcpOppositePort:this.inputTextList1[1],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[6],centerIp:this.inputTextList1[2],centerPort:this.inputTextList1[3]} - fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param)) + fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param),'') // upDateTableByArray('IpConfigTable',[]) ethernet.setIfaceConfig("eth0", { mode: 0, diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index e04a2779..b49b5cca 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -310,16 +310,22 @@ struct UserInfo { 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') + const openCheckFlag =openCheckFlagParam?.[0]?.v_value == '1' ? '1' : '0' + const faceParam = syssetParams.filter(sys => sys.v_no == '2413') - that.FaceOpenStatue = faceParam?.[0]?.v_value == '3' ? '1' : '0' - that.FaceOpenStatue = '0' + // that.FaceOpenStatue = '0' // faceParam?.[0]?.v_value || // 1身份证读卡器 2指纹 3人脸 - this.faceFlag = faceParam?.[0]?.v_value || '0' - if (faceParam?.[0]?.v_value == '1') { - that.openDeviceByIDCard() + 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() + } } + //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 if (that.studentRefreshStatue == '2') { clearInterval(that.interval) From 829a18a314f8f74520ab942f063124a08509f1fb Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Tue, 13 Aug 2024 11:50:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B4=9B=E9=99=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/common/service/indexService.ts | 8 +-- entry/src/main/ets/common/service/initable.ts | 2 +- .../ets/common/service/terminalService.ts | 7 +-- .../ets/common/utils/UdpClientByCenter.ts | 60 +++++++++---------- entry/src/main/ets/pages/Index.ets | 8 ++- entry/src/main/ets/pages/TerminalInfos.ets | 38 ++++++------ entry/src/main/ets/pages/UserInfo.ets | 6 +- 7 files changed, 65 insertions(+), 64 deletions(-) diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index 6818a8e4..a91c34ba 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -152,10 +152,10 @@ export async function getSingleCenterTable(param) { // reslove(false) // }) console.log('联网更新失败,请检查网络后重新更新') - promptAction.showToast({ - message: `联网更新表数据失败,请重新更新`, - duration: 3000 - }); + // promptAction.showToast({ + // message: `联网更新表数据失败,请重新更新`, + // duration: 3000 + // }); reslove(false) } }).catch((error) => { diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 571d620f..4946d97d 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -337,7 +337,7 @@ export async function upDataZhongxinginitialization(param) { const tableList=['MA_ITEMINFO','MA_MARKRULE','MA_SYSTEMPARM','MA_MAP_COLLECT','MA_MAP_COLLECT_SHAPE','MA_MAP_ITEMCLASS','MA_MAP_POINT','MA_MAP_POINT_ITEM','MA_MAP_ROAD','MA_MAP_ROAD_LANE','MAP_SUBITEM','MA_SYSSET','ES_CARINFO','MA_MARKRULESET','MA_CDSBINFO','MA_T_CARPARMSET']; tableList.map(async(tableName)=>{ const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + `/config/tableList/${tableName}.txt`); - if(data&&JSON.parse(data)&&JSON.parse(data).length>0){ + if(data&&JSON.parse(data)){ sqlInsertCommonFn(tableName, JSON.parse(data), param.context).then((result) => { console.log(key, '单机表建立成功') if (result) { diff --git a/entry/src/main/ets/common/service/terminalService.ts b/entry/src/main/ets/common/service/terminalService.ts index f1f06a9d..c497f177 100644 --- a/entry/src/main/ets/common/service/terminalService.ts +++ b/entry/src/main/ets/common/service/terminalService.ts @@ -3,7 +3,6 @@ import { obtainCarExamInfo } from '../../api/index' import { dateFormat } from '../utils/tools' import router from '@ohos.router' import promptAction from '@ohos.promptAction' -import { getSyncData } from '../../common/service/initable' import { GlobalConfig } from '../../config/index' import FileUtil from '../../common/utils/File' @@ -14,8 +13,6 @@ export async function getDeviceInfo(context) { // globalThis.deviceNo = '1649018001275'; //洛阳科目三设备 // globalThis.deviceNo = 'MAC-36E6575F'; //杭州科目二设备 489 // globalThis.deviceNo = 'MAC-C57C8966'; //杭州科目二设备 - globalThis.deviceNo = 'MAC-B2A3A8FD'; //杭州科目二设备 - return return new Promise(async (resolve, reject) => { const fileUtil = new FileUtil(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt'); @@ -25,11 +22,11 @@ export async function getDeviceInfo(context) { duration: 3000 }); router.pushUrl({ - url: 'pages/Register', + url: 'pages/Register', }, router.RouterMode.Single); resolve('') } else { - const fileData=JSON.parse(data) + const fileData = JSON.parse(data) globalThis.deviceNo = fileData.deviceName getCarInfo() resolve(fileData.deviceName) diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index cb4667b3..b81158e7 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -22,6 +22,7 @@ import { fillZero, string2Bytes } from '../utils/tools' const TAG = '[UdpDemo.UdpClient]' import hilog from '@ohos.hilog'; import prompt from '@ohos.prompt' +import { getUDP } from './GlobalUdp'; export default class UdpClientByCenter { @@ -59,7 +60,9 @@ export default class UdpClientByCenter { return this.isWorking } - rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) { + rebindUdp(localIp: string, localIpPort: string, oppositeIp: string, oppositeIpPort: string) + { + console.log(`${TAG}getUDPudpCLient rebindUdp enter localIp:${localIp},localIpPort:${localIpPort},oppositeIp:${oppositeIp},oppositeIpPort:${oppositeIpPort}`); this.localIp = localIp this.oppositeIp = oppositeIp this.localIpPort = localIpPort @@ -152,33 +155,31 @@ export default class UdpClientByCenter { console.log('getUDPsendHeadMsg exit') } - sendMsg(msg, sendCallback?) { - if (!this.isWorking && sendCallback) { - sendCallback() - } - this.udp.getState((err, data) => { - if (err) { - this.isWorking = false - return; - } else { - let promise = this.udp.send({ - data: msg, - address: { - address: this.oppositeIp, - port: parseInt(this.oppositeIpPort), - } - }); - promise.then(() => { - if (sendCallback) { - sendCallback() - } - console.log(`${TAG}getUDPudpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); - }).catch(err => { - console.log(`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); - }); + sendMsg(msg, sendCallback?) + { + console.log(`${TAG}getUDPudpCLient sendMsg enter oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`); + if (!this.isWorking ) { + console.log(`${TAG}getUDPudpCLient sendMsg is closed return `); + if(sendCallback) { + sendCallback() } - console.log('getUDPgetState success:' + JSON.stringify(data)); - }) + return; + } + let promise = this.udp.send({ + data: msg, + address: { + address: this.oppositeIp, + port: parseInt(this.oppositeIpPort), + } + }); + promise.then(() => { + if (sendCallback) { + sendCallback() + } + console.log(`${TAG}getUDPudpCLient udp send success:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); + }).catch(err => { + console.log(`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`); + }); } sendMsgExt(param, context?) { @@ -329,9 +330,8 @@ export default class UdpClientByCenter { num++ console.log(TAG, 'plc udp信号丢失') if (num == 3) { - await this.bindUdp() - await this.sendMsg('111', null) - await this.onMessage_1(callback) + getUDP(globalThis.context,true) + num = 0 } prompt.showToast({ diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 6bf37220..4c21e7b6 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -48,9 +48,11 @@ struct Index { .margin({ bottom: 12 * this.ratio}) } // dialogController: CustomDialogController | null = new CustomDialogController({ - // builder: errorMsgDialog({ - // cancel: ()=> { this.onCancel() }, - // confirm: ()=> { this.onAccept() } + // builder: errorMsgDialog( + // title, + // isDialog, + // // cancel: ()=> { }, + // // confirm: ()=> { } // }) build() { Column() { diff --git a/entry/src/main/ets/pages/TerminalInfos.ets b/entry/src/main/ets/pages/TerminalInfos.ets index a805856a..6813c5f3 100644 --- a/entry/src/main/ets/pages/TerminalInfos.ets +++ b/entry/src/main/ets/pages/TerminalInfos.ets @@ -6,6 +6,7 @@ import { upDateTableByArray} from '../common/service/initable' import { getSyncData} from '../common/service/initable' import FileUtil from '../common/utils/File'; import common from '@ohos.app.ability.common'; +import { GlobalConfig } from '../config'; @Entry @@ -131,27 +132,30 @@ struct Index { .backgroundImageSize({ width: '100%', height: '100%' }) } - aboutToAppear() { - getSyncData('IpConfigTable').then((result:Array)=>{ - console.log('result222',JSON.stringify(result)) - if(result.length){ + async aboutToAppear() { + const fileUtil = new FileUtil(this.context) + const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); + if (data === '' || data === undefined) { + }else{ + const result=JSON.parse(data) console.log('tagtag',JSON.stringify(result)) - this.inputTextList1[9]=result[0].udplocalIp - this.inputTextList1[10]=result[0].udplocalIpPort - this.inputTextList1[7]=result[0].udpOppositeIp - this.inputTextList1[8]=result[0].udpOppositeIpPort + this.inputTextList1[9]=result.udplocalIp + this.inputTextList1[10]=result.udplocalIpPort + this.inputTextList1[7]=result.udpOppositeIp + this.inputTextList1[8]=result.udpOppositeIpPort // this.inputTextList1[0]=result[0].tcplocalIp // this.inputTextList1[13]=result[0].tcplocalIpPort - this.inputTextList1[0]=result[0].tcpOppositeIp - this.inputTextList1[1]=result[0].tcpOppositePort - this.inputTextList1[5]=result[0].gateway - this.inputTextList1[4]=result[0].netMask - this.inputTextList1[6]=result[0].dnsServers - this.inputTextList1[2]=result[0].centerIp - this.inputTextList1[3]=result[0].centerPort - } - }) + this.inputTextList1[0]=result.tcpOppositeIp + this.inputTextList1[1]=result.tcpOppositePort + this.inputTextList1[5]=result.gateway + this.inputTextList1[4]=result.netMask + this.inputTextList1[6]=result.dnsServers + this.inputTextList1[2]=result.centerIp + this.inputTextList1[3]=result.centerPort + } + + ethernet.getIfaceConfig("eth0", (error, value) => { if (error) { // that.errorMsg='error' diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 83a6721e..fbd3e65c 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -28,7 +28,6 @@ import { initJudgeUdp } from '../common/utils/UdpJudge'; struct UserInfo { private filePhoto: FilePhoto private avPlayer - @State pageIndex: number = 0 @State ratio: number = 1700 / 960 @State index: number = 0 @@ -70,10 +69,9 @@ struct UserInfo { @State numCount: number = 0; @State signNum: number = 0; @State isCanClick: boolean = true; - @State updateTimeLimit: boolean = true + @State updateTimeLimit: boolean = false @State faceFlag: string = '0'; @State FaceOpenStatue: string = '0'; //是否开启人脸识别 - subscriber; @State faceCatchImg: string = '' @State Param803Str:string = '' // 过程照片拍照 @@ -380,7 +378,7 @@ struct UserInfo { //获取下载考生 getExaminationStudentInfoFn() { - if (globalThis.singlePlay && this.updateTimeLimit) { + if (globalThis.singlePlay || this.updateTimeLimit) { return } const param = `${Md5.Instance.get_md5(globalThis.carInfo.carId + globalThis.carInfo.examinationRoomId + globalThis.username)}${globalThis.carInfo.carId}${globalThis.carInfo.examinationRoomId}${globalThis.username}` From f974da93030cb31cf8f47529262d22021dfe48f5 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Wed, 14 Aug 2024 09:18:33 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A4=96=E6=AE=BC=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/common/service/terminalService.ts | 11 ++--------- entry/src/main/ets/common/utils/TcpClient.ts | 1 + entry/src/main/ets/common/utils/UdpClient.ts | 11 ++++++----- entry/src/main/ets/entryability/EntryAbility.ts | 2 ++ entry/src/main/ets/pages/Index.ets | 11 +++++++---- entry/src/main/ets/pages/Settings.ets | 2 +- entry/src/main/ets/pages/UserInfo.ets | 2 +- entry/src/main/ets/pages/VideoConfig.ets | 4 ++-- entry/src/main/ets/pages/compontents/FaceCompare.ets | 3 +-- 9 files changed, 23 insertions(+), 24 deletions(-) diff --git a/entry/src/main/ets/common/service/terminalService.ts b/entry/src/main/ets/common/service/terminalService.ts index c497f177..3fc82a30 100644 --- a/entry/src/main/ets/common/service/terminalService.ts +++ b/entry/src/main/ets/common/service/terminalService.ts @@ -3,16 +3,12 @@ import { obtainCarExamInfo } from '../../api/index' import { dateFormat } from '../utils/tools' import router from '@ohos.router' import promptAction from '@ohos.promptAction' +import { getSyncData } from '../../common/service/initable' import { GlobalConfig } from '../../config/index' import FileUtil from '../../common/utils/File' //获取设备信息 export async function getDeviceInfo(context) { - // globalThis.deviceNo = '153216400880'; //科目三设备 - // globalThis.deviceNo = '150667400235'; //科目三设备 - // globalThis.deviceNo = '1649018001275'; //洛阳科目三设备 - // globalThis.deviceNo = 'MAC-36E6575F'; //杭州科目二设备 489 - // globalThis.deviceNo = 'MAC-C57C8966'; //杭州科目二设备 return new Promise(async (resolve, reject) => { const fileUtil = new FileUtil(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt'); @@ -21,12 +17,9 @@ export async function getDeviceInfo(context) { message: `请先进行设备注册`, duration: 3000 }); - router.pushUrl({ - url: 'pages/Register', - }, router.RouterMode.Single); resolve('') } else { - const fileData = JSON.parse(data) + const fileData=JSON.parse(data) globalThis.deviceNo = fileData.deviceName getCarInfo() resolve(fileData.deviceName) diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 96f9e90f..ad2e7a25 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -181,6 +181,7 @@ export default class TcpClient { let promise = this.tcp.close(); promise.then(() => { globalThis.getCloseTcp = true + console.log(TAG, 'tcpCloseSuccess') callback() reslove(true) diff --git a/entry/src/main/ets/common/utils/UdpClient.ts b/entry/src/main/ets/common/utils/UdpClient.ts index 23433ef5..8f2ae9c4 100644 --- a/entry/src/main/ets/common/utils/UdpClient.ts +++ b/entry/src/main/ets/common/utils/UdpClient.ts @@ -16,7 +16,7 @@ import socket from '@ohos.net.socket'; import { Array2Byte } from '../utils/tools' import {getChuankouFn} from '../../common/service/indexService' - +import {getUDP} from './GlobalUdp' const TAG = 'socketTag[PLC.UdpClient]' import prompt from '@ohos.prompt' @@ -29,7 +29,7 @@ export default class UdpClient { private oppositeIpPort: string = '' private udp: any = null - // private stashFn:StashFuncotion + // private stashFn:StashFuncotionon constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { this.localIp = udplocalIp @@ -179,9 +179,10 @@ export default class UdpClient { num++ console.log(TAG,'plc udp信号丢失') if(num==3){ - await this.bindUdp() - await this.sendMsg('111') - await this.onMessage(callback) + getUDP(globalThis.context,true) + // await this.bindUdp() + // await this.sendMsg('111') + // await this.onMessage(callback) num=0 } prompt.showToast({ diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 983a375a..f3b0e18c 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -30,6 +30,8 @@ export default class EntryAbility extends UIAbility { globalThis.hasAuth = false globalThis.version = '2022.08.13.01' globalThis.judgeVersion = '2022.12.05.1' + // 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/Index.ets b/entry/src/main/ets/pages/Index.ets index 4c21e7b6..35a73430 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -311,6 +311,7 @@ struct Index { carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId } + console.log('paramparam',JSON.stringify(param)) // globalThis.udpClient2.initHeartSendMsg(param,this.context) if (globalThis.udpClient2.getStatus()) { globalThis.udpClient2.sendMsgExt(param, this.context) @@ -333,8 +334,7 @@ struct Index { this.loading = false this.userAuth(); this.createAlbum() - await getUDP(this.context,false) - await getUDP2(this.context,false) + this.num=0 clearInterval(this.interval) this.interval = setInterval(() => { @@ -347,7 +347,6 @@ struct Index { }, 1000) // - getTCP() // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) console.info('Index onPageShow'); @@ -388,8 +387,12 @@ struct Index { async initParams() { this.loading = false takePhotoFn(this.context) - this.deviceId=await getDeviceInfo(this.context) || '' + await getDeviceInfo(this.context) await getCarInfo() + await getUDP(this.context,false) + await getUDP2(this.context,false) + getTCP() + this.deviceId= globalThis.carInfo.carNo await setCurrentTime(); this.carNum = globalThis.carInfo.plateNo; this.version = globalThis.version; diff --git a/entry/src/main/ets/pages/Settings.ets b/entry/src/main/ets/pages/Settings.ets index daa47348..6e490924 100644 --- a/entry/src/main/ets/pages/Settings.ets +++ b/entry/src/main/ets/pages/Settings.ets @@ -55,7 +55,7 @@ export default struct Index { } .margin({ left: 24 * this.ratio }) - Text('考车号:' + globalThis.deviceNo) + Text('考车号:' + globalThis.carInfo.carNo) .fontColor('#CCAE7A') .fontSize(22 * this.ratio) .margin({ right: 24 * this.ratio }) diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index fbd3e65c..0f8b0c37 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -316,7 +316,6 @@ struct UserInfo { const faceParam = syssetParams.filter(sys => sys.v_no == '2413') - // that.FaceOpenStatue = '0' // faceParam?.[0]?.v_value || // 1身份证读卡器 2指纹 3人脸 if(openCheckFlag=='1'){ @@ -326,6 +325,7 @@ struct UserInfo { that.openDeviceByIDCard() } } + // that.FaceOpenStatue = '0' //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 if (that.studentRefreshStatue == '2') { diff --git a/entry/src/main/ets/pages/VideoConfig.ets b/entry/src/main/ets/pages/VideoConfig.ets index a64d4abb..e09fb7b9 100644 --- a/entry/src/main/ets/pages/VideoConfig.ets +++ b/entry/src/main/ets/pages/VideoConfig.ets @@ -217,7 +217,7 @@ struct Index { this.param.faceFlag = value console.info('Checkbox1 change is' + value) }) - Text('启用过程人脸比对').fontColor('#333333').fontSize(16 * this.ratio) + Text('启用人脸比对').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.rlls, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) @@ -229,7 +229,7 @@ struct Index { .onChange((value) => { this.param.rlls = value }) - Text('拍照通道').fontColor('#333333').fontSize(16 * this.ratio) + Text('过程拍照通道').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.pztd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) diff --git a/entry/src/main/ets/pages/compontents/FaceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets index 8a05b977..232a38d7 100644 --- a/entry/src/main/ets/pages/compontents/FaceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -178,7 +178,7 @@ export default struct FaceCompare { async faceComparFn() { console.log('mmmmm0', 2) - + this.param.pztd=this.param.rlls const data=await takePhoto(this.param, this.context, 'jt/', 1,) this.base64=this.imageBase64 + data.base64 console.log('mmmmt',this.base64) @@ -191,7 +191,6 @@ export default struct FaceCompare { }) .then(res => { console.log('mmmmm8', res) - if (res) { this.controller.stop() this.showFaceCompare = !this.showFaceCompare From 3b121ed5b24d3913807c314bc0d66d14e7d700b0 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Wed, 14 Aug 2024 13:15:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A4=96=E6=AE=BC=E5=84=AA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/TcpClient.ts | 13 +++++++++++++ entry/src/main/ets/pages/Index.ets | 11 ++++++----- .../src/main/ets/pages/compontents/FaceCompare.ets | 6 +++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index ad2e7a25..79c8d7cd 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -152,6 +152,7 @@ export default class TcpClient { onMessage(callback?) { this.tcp.on('message', value => { console.log(TAG, 'Tcponmessage', value.length, value) + globalThis.tcpUdpError = false // console.log('messageLengt',,value.message.length)) console.log('testTagtcpmsg') @@ -165,6 +166,18 @@ export default class TcpClient { } else { callback && callback('') } + setTimeout(async () => { + //程序断开 + if (globalThis.tcpUdpError) { + this.num++ + console.log(TAG,'tcp信号丢失') + if(this.num==3){ + getTCP() + this.num=0 + } + } + globalThis.tcpUdpError = true; + }, 2000) // callback(value.message) }); } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 35a73430..919fee2b 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -319,6 +319,7 @@ struct Index { } async onPageShow() { + this.userAuth(); this.vocObj = new voiceService(async (status, val, next) => { }); @@ -332,7 +333,6 @@ struct Index { } this.isSingle = globalThis.singlePlay this.loading = false - this.userAuth(); this.createAlbum() this.num=0 @@ -385,13 +385,14 @@ struct Index { } async initParams() { + //设置plc udp 同步requesthost + await getUDP(this.context,false) this.loading = false takePhotoFn(this.context) await getDeviceInfo(this.context) - await getCarInfo() - await getUDP(this.context,false) - await getUDP2(this.context,false) - getTCP() + // await getCarInfo() + // await getUDP2(this.context,false) + // getTCP() this.deviceId= globalThis.carInfo.carNo await setCurrentTime(); this.carNum = globalThis.carInfo.plateNo; diff --git a/entry/src/main/ets/pages/compontents/FaceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets index 232a38d7..ae138df9 100644 --- a/entry/src/main/ets/pages/compontents/FaceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -45,7 +45,7 @@ export default struct FaceCompare { Column() { Column() { Text('照片比对') - .lineHeight('16%') + // .lineHeight('16%') .height('16%') .fontWeight(FontWeight.Bold) .fontSize(24) @@ -78,11 +78,11 @@ export default struct FaceCompare { .height('100%') } .width('88.9%') - .height('53.2%') + .height('52%') .justifyContent(FlexAlign.SpaceBetween) Text('正在等待拍照…') - .lineHeight('16%') + // .lineHeight('16%') .height('16%') .fontWeight(FontWeight.Bold) .fontColor('#CC7E00') From b89b0c911ef52dc1ca896e48b907409f4d13c145 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Wed, 14 Aug 2024 14:46:33 +0800 Subject: [PATCH 5/5] =?UTF-8?q?tcp=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/service/terminalService.ts | 8 +++-- entry/src/main/ets/common/utils/GlobalUdp.ts | 4 ++- entry/src/main/ets/common/utils/TcpClient.ts | 25 +++++++++------ entry/src/main/ets/common/utils/UdpClient.ts | 8 ++--- entry/src/main/ets/common/utils/request.ts | 27 ++++++++++++++-- entry/src/main/ets/pages/Index.ets | 31 +++++++++++-------- 6 files changed, 71 insertions(+), 32 deletions(-) diff --git a/entry/src/main/ets/common/service/terminalService.ts b/entry/src/main/ets/common/service/terminalService.ts index 3fc82a30..09f5fa15 100644 --- a/entry/src/main/ets/common/service/terminalService.ts +++ b/entry/src/main/ets/common/service/terminalService.ts @@ -12,6 +12,7 @@ export async function getDeviceInfo(context) { return new Promise(async (resolve, reject) => { const fileUtil = new FileUtil(context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/deviceNo.txt'); + console.log('globalThis.deviceNoglobalThis.deviceNo',data) if (data === '' || data === undefined) { promptAction.showToast({ message: `请先进行设备注册`, @@ -21,7 +22,8 @@ export async function getDeviceInfo(context) { } else { const fileData=JSON.parse(data) globalThis.deviceNo = fileData.deviceName - getCarInfo() + console.log('globalThis.deviceNo', globalThis.deviceNo) + // getCarInfo() resolve(fileData.deviceName) } }) @@ -30,6 +32,8 @@ export async function getDeviceInfo(context) { //获取考车信息 export async function getCarInfo() { let date = new Date(); + console.log('globalThis.carInfo2222', globalThis.deviceNo) + let params = { time: dateFormat(date), deviceNo: globalThis.deviceNo }; let res: any = await obtainCarExamInfo(params) if (!res?.obtainCarExamInfoRsp?.body) { @@ -38,7 +42,7 @@ export async function getCarInfo() { // }, router.RouterMode.Single); } else { globalThis.carInfo = res.obtainCarExamInfoRsp.body - console.log('globalThis.carInfo', JSON.stringify(globalThis.carInfo)); + console.log('globalThis.carInfo2222', JSON.stringify(res)); // globalThis.carInfo.carId=res.obtainCarExamInfoRsp.body.carId globalThis.carInfo.plateNo = decodeURIComponent(globalThis.carInfo.plateNo) } diff --git a/entry/src/main/ets/common/utils/GlobalUdp.ts b/entry/src/main/ets/common/utils/GlobalUdp.ts index a1342b01..005803d6 100644 --- a/entry/src/main/ets/common/utils/GlobalUdp.ts +++ b/entry/src/main/ets/common/utils/GlobalUdp.ts @@ -13,6 +13,7 @@ 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) if (data === '' || data === undefined) { console.log(` getUDP has no IPConfigTable `); globalThis.udpClient = {} @@ -45,6 +46,7 @@ export async function getUDP(context,errorFlag?) { else { // 未绑定 console.log(` getUDP has no udclent and bind `); + console.log('ttttttdata',JSON.stringify(result)) const udpClient: UdpClientByCenter = new UdpClientByCenter(result.udplocalIp, result.udplocalIpPort, result.udpOppositeIp, result.udpOppositeIpPort) udpClient.bindUdp() udpClient.sendMsg('111') @@ -62,7 +64,7 @@ export async function getUDP(context,errorFlag?) { } }) getChuankouFn() - reslove(`http://${result[0].centerIp}:${result[0].centerPort}`) + reslove(`http://${result.centerIp}:${result.centerPort}`) } diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 79c8d7cd..4452f33d 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -1,6 +1,7 @@ import socket from '@ohos.net.socket'; import hilog from '@ohos.hilog'; import { getTCP } from './GlobalTcp'; +import prompt from '@ohos.prompt'; const TAG = 'socketTag[TcpDemo.TcpClient]' @@ -166,18 +167,22 @@ export default class TcpClient { } else { callback && callback('') } - setTimeout(async () => { - //程序断开 - if (globalThis.tcpUdpError) { - this.num++ - console.log(TAG,'tcp信号丢失') - if(this.num==3){ + clearInterval(globalThis.intervaltcp) + globalThis.intervaltcp=setInterval(()=>{ + setTimeout(async () => { + //程序断开 + if (globalThis.tcpUdpError) { + console.log(TAG,'tcp信号丢失') getTCP() - this.num=0 + prompt.showToast({ + message: 'tcp信号丢失', + duration: 2000 + }); } - } - globalThis.tcpUdpError = true; - }, 2000) + globalThis.tcpUdpError = true; + }, 2000) + },3000) + // callback(value.message) }); } diff --git a/entry/src/main/ets/common/utils/UdpClient.ts b/entry/src/main/ets/common/utils/UdpClient.ts index 8f2ae9c4..0de4a2f9 100644 --- a/entry/src/main/ets/common/utils/UdpClient.ts +++ b/entry/src/main/ets/common/utils/UdpClient.ts @@ -176,15 +176,15 @@ export default class UdpClient { //程序断开 lightLineUdp?.send(globalThis.plcUdpError ? arrRedBuffer : (isJudge ? arrGreenBugger : arrBlueBuffer)); if (globalThis.plcUdpError) { - num++ + // num++ console.log(TAG,'plc udp信号丢失') - if(num==3){ + // if(num==3){ getUDP(globalThis.context,true) // await this.bindUdp() // await this.sendMsg('111') // await this.onMessage(callback) - num=0 - } + // num=0 + // } prompt.showToast({ message: 'plc udp信号丢失', duration: 2000 diff --git a/entry/src/main/ets/common/utils/request.ts b/entry/src/main/ets/common/utils/request.ts index 67b8dd70..b963036c 100644 --- a/entry/src/main/ets/common/utils/request.ts +++ b/entry/src/main/ets/common/utils/request.ts @@ -3,6 +3,9 @@ import convertxml from '@ohos.convertxml'; import prompt from '@ohos.prompt' import { sendGreen } from '../../pages/judgeSDK/utils/judgeCommon'; import {GlobalConfig} from '../../config/index' +import FileUtil from '../../common/utils/File'; +import { dateFormat } from '../utils/tools' + const config = { host:GlobalConfig.host, } @@ -36,16 +39,31 @@ export default async function request(req: any) { try { let baseUrl=host?host:globalThis.host // let baseUrl=host?config.csptHost:config.host' - console.log('响应头地址' + paramsStr) + + console.log('响应头地址' + baseUrl) + // writeLog({ + // time:dateFormat(new Date()), + // url, + // extraData: JSON.stringify(data), + // state:'start' + // }) const {result,responseCode} = await httpRequest.request(`${baseUrl}${url}${paramsStr}`, options); + // fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(arrList)) + // writeLog({ + // time:dateFormat(new Date()), + // url, + // result:JSON.stringify(result), + // extraData: JSON.stringify(data), + // state:'end' + // }) console.log('响应头地址' + JSON.stringify(result)) let res:any = xml ? xmlToJson(result,url) : result; console.log('响应头地址' + JSON.stringify(res)) + let resObj = null; if(typeof res === "string"){ res=JSON.parse(res) } - //处理中心服务code if(res.Envelope){ const msgXml = res.Envelope.Body.writeObjectOutResponse.return; @@ -99,7 +117,12 @@ export default async function request(req: any) { } } +async function writeLog(param){ + const fileUtil = new FileUtil(globalThis.context) + const folderPath = await fileUtil.initFolder(`/errorMsg/`); + fileUtil.editFile(`${folderPath}/request.txt`, JSON.stringify(param)+`\n`) +} //xml格式转JSON function xmlToJson(result,url) { console.log("xmlToJson begin",url); diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 919fee2b..8d3a72ec 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -319,7 +319,10 @@ struct Index { } async onPageShow() { + console.log('ttttt',1111) this.userAuth(); + console.log('ttttt2222',1111) + this.vocObj = new voiceService(async (status, val, next) => { }); @@ -336,15 +339,7 @@ struct Index { this.createAlbum() this.num=0 - clearInterval(this.interval) - this.interval = setInterval(() => { - this.num++ - setliushuiNum(this.context) - getliushuiNum(this.context) - if(this.num>=3){ - this.heartMsg() - } - }, 1000) + // // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) @@ -388,18 +383,28 @@ struct Index { //设置plc udp 同步requesthost await getUDP(this.context,false) this.loading = false - takePhotoFn(this.context) + console.log('globalThis.deviceNo000') await getDeviceInfo(this.context) - // await getCarInfo() - // await getUDP2(this.context,false) - // getTCP() + await getCarInfo() + await getUDP2(this.context,false) + getTCP() this.deviceId= globalThis.carInfo.carNo await setCurrentTime(); this.carNum = globalThis.carInfo.plateNo; this.version = globalThis.version; this.hasAuth = globalThis.hasAuth; initJudgeUdp() + takePhotoFn(this.context) console.log('deviceIddeviceId',globalThis.deviceNo,this.deviceNo) + clearInterval(this.interval) + this.interval = setInterval(() => { + this.num++ + setliushuiNum(this.context) + getliushuiNum(this.context) + if(this.num>=3){ + this.heartMsg() + } + }, 1000) //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]