From 7ba4c2f5f0a33ee374dd7f7b6bb4233b6a5c92f3 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Mon, 26 Aug 2024 19:27:23 +0800 Subject: [PATCH] =?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/constants/USER.ts | 4 +- .../src/main/ets/common/constants/USERLIST.ts | 4 +- .../main/ets/common/service/indexService.ts | 1 + entry/src/main/ets/common/service/initable.ts | 17 ++-- entry/src/main/ets/common/utils/TcpClient.ts | 57 +++++------ .../ets/common/utils/UdpClientByCenter.ts | 96 +++++++++---------- entry/src/main/ets/common/utils/tools.ts | 1 + entry/src/main/ets/pages/Index.ets | 21 ++-- entry/src/main/ets/pages/UserInfo.ets | 6 +- .../ets/pages/compontents/FaceCompare.ets | 11 ++- 10 files changed, 117 insertions(+), 101 deletions(-) diff --git a/entry/src/main/ets/common/constants/USER.ts b/entry/src/main/ets/common/constants/USER.ts index 93a97f0d..51dee8d7 100644 --- a/entry/src/main/ets/common/constants/USER.ts +++ b/entry/src/main/ets/common/constants/USER.ts @@ -25,8 +25,8 @@ CommonConstants { */ static readonly ACCOUNT_TABLE = { tableName: 'USER', - sqlCreate: 'CREATE TABLE IF NOT EXISTS USER(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT)', - columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1'] + sqlCreate: 'CREATE TABLE IF NOT EXISTS USER(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT,ksmjzp TEXT)', + columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1','ksmjzp'] }; /** diff --git a/entry/src/main/ets/common/constants/USERLIST.ts b/entry/src/main/ets/common/constants/USERLIST.ts index 0c01e61d..879fea87 100644 --- a/entry/src/main/ets/common/constants/USERLIST.ts +++ b/entry/src/main/ets/common/constants/USERLIST.ts @@ -25,8 +25,8 @@ CommonConstants { */ static readonly ACCOUNT_TABLE = { tableName: 'USERLIST', - sqlCreate: 'CREATE TABLE IF NOT EXISTS USERLIST(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT)', - columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1'] + sqlCreate: 'CREATE TABLE IF NOT EXISTS USERLIST(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT,ksmjzp TEXT)', + columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1','ksmjzp'] }; /** diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index d8f8d648..bec0cf8a 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -161,6 +161,7 @@ export async function getDoubleCeneterTable(param) { export async function getSingleCenterTable(param) { return new Promise((reslove, reject) => { try{ + console.log('teststet0') upDataZhongxinginitialization(param).then((result) => { console.log('kkkkkkkkkkk',result) diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index 8c18e11d..b5039a12 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -339,11 +339,6 @@ export async function getEsCarModel(context) { export async function upDataZhongxinginitialization(param) { return new Promise(async(resolve, reject) => { console.log('teststet00',JSON.stringify(param)) - - if (!param.carId) { - resolve(false) - return - } let flag=true if (param.singlePlay) { console.log('teststet0',JSON.stringify(param)) @@ -366,6 +361,10 @@ export async function upDataZhongxinginitialization(param) { resolve(flag) return } + if (!param.carId) { + resolve(false) + return + } try{ const str = { "carId": param.carId, // 表名 @@ -446,10 +445,10 @@ function setSyncCenterSqlData(key, res, param) { console.log('mapName[key]', mapName[key], key) sqlInsertCommonFn(mapName[key], arrList, param.context).then((result) => { console.log(key, '表建立成功') - writeLog('PLC',{ - time:dateFormat(new Date()), - PLC:`${key} 表建立成功`, - }) + // writeLog('PLC',{ + // time:dateFormat(new Date()), + // PLC:`${key} 表建立成功`, + // }) if (result) { resolve(true) } else { diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index d5f02aec..110c9c08 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -27,10 +27,10 @@ export default class TcpClient { onError(callback?) { this.tcp.on('error', err => { - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} tcpOnerror ${JSON.stringify(err)}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} tcpOnerror ${JSON.stringify(err)}`, + // }) console.log(TAG, 'tcpOnerror', JSON.stringify(err)) setTimeout(async () => { getTCP() @@ -78,10 +78,10 @@ export default class TcpClient { address: this.localIp, port: parseInt(this.localIpPort), family: 1 }, err => { if (err) { - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} testTag tcp bind faile ${JSON.stringify(err)}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} testTag tcp bind faile ${JSON.stringify(err)}`, + // }) console.log('testTag tcp bind faile'); globalThis.getCloseTcp = true hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err)); @@ -90,10 +90,10 @@ export default class TcpClient { } globalThis.getCloseTcp = false console.log('testTag tcp bind success'); - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} testTag tcp bind success`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} testTag tcp bind success`, + // }) resolve(false) }) }) @@ -122,10 +122,10 @@ export default class TcpClient { keepAlive: true, }, err => { if (err) { - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} tcp connect rebind success`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} tcp connect rebind success`, + // }) if(this.num>3){ return } @@ -150,10 +150,10 @@ export default class TcpClient { getTCP() resolve(false) }, 2000) - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} tcp connect error`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} tcp connect error`, + // }) }); }) } @@ -174,10 +174,10 @@ export default class TcpClient { onMessage(callback?) { this.tcp.on('message', value => { - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} Tcponmessage`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} Tcponmessage`, + // }) console.log(TAG, 'Tcponmessage', value) globalThis.tcpUdpError = false @@ -212,10 +212,11 @@ export default class TcpClient { }); } 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`) + // return + // 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`) } offTcp(callback) { diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index d14f934e..bef8ac0d 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -86,17 +86,17 @@ export default class UdpClientByCenter { // globalThis.closeHeartSocket=false this.isWorking = true console.log(`${TAG} getUDPudp rebind success`); - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} getUDPudp rebind success`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} getUDPudp rebind success`, + // }) }).catch(err => { //globalThis.closeHeartSocket=true this.isWorking = false - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`, + // }) console.log(`${TAG} getUDPudp rebind failed:${JSON.stringify(err)}`); }); } @@ -107,16 +107,16 @@ export default class UdpClientByCenter { }); promise.then(() => { this.isWorking = true - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} getUDPudp bind success`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} getUDPudp bind success`, + // }) }).catch(err => { this.isWorking = false - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG} getUDPudp bind error${JSON.stringify(err)},localIp:${this.localIpPort},port:${this.localIpPort}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG} getUDPudp bind error${JSON.stringify(err)},localIp:${this.localIpPort},port:${this.localIpPort}`, + // }) }); } @@ -182,10 +182,10 @@ export default class UdpClientByCenter { { if (!this.isWorking ) { console.log(`${TAG}getUDPudpCLient sendMsg is closed return `); - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG}getUDPudpCLient sendMsg is closed return oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG}getUDPudpCLient sendMsg is closed return oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`, + // }) if(sendCallback) { sendCallback() } @@ -202,15 +202,15 @@ export default class UdpClientByCenter { if (sendCallback) { sendCallback() } - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG}getUDPudpCLient udp send success: oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG}getUDPudpCLient udp send success: oppositeIp:${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort:${this.localIpPort}`, + // }) }).catch(err => { - this.writeLog({ - time:dateFormat(new Date()), - PLC:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}${JSON.stringify(err)}`, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}${JSON.stringify(err)}`, + // }) promptAction.showToast({ message:`${TAG}getUDPudpCLient udp send fail:oppositeIp${this.oppositeIp},oppositeIpPort:${this.oppositeIpPort},localIp:${this.localIp},localIpPort,${this.localIpPort}`, duration:4000 @@ -231,10 +231,10 @@ export default class UdpClientByCenter { onError_Callback(callback?) { this.udp.on('error', async err => { this.isWorking = false; - this.writeLog({ - time:dateFormat(new Date()), - PLC:'getUDPUdpClientByCenter onError err:' + JSON.stringify(err)+this.oppositeIpPort, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:'getUDPUdpClientByCenter onError err:' + JSON.stringify(err)+this.oppositeIpPort, + // }) callback && callback() }); } @@ -288,19 +288,19 @@ export default class UdpClientByCenter { console.log('getUDPUdpClientByCenter enter closeUdp ip:' + this.localIp + ' port:' + this.localIpPort); this.udp.close(err => { if (err) { - this.writeLog({ - time:dateFormat(new Date()), - PLC:'getUDPUdpClientByCenter closeUdp err:' + JSON.stringify(err)+this.oppositeIpPort, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:'getUDPUdpClientByCenter closeUdp err:' + JSON.stringify(err)+this.oppositeIpPort, + // }) } else { this.isWorking = false if (callback != null) { callback() } - this.writeLog({ - time:dateFormat(new Date()), - PLC:'getUDPUdpClientByCenter closeUdp succeed:' + JSON.stringify(err)+this.oppositeIpPort, - }) + // this.writeLog({ + // time:dateFormat(new Date()), + // PLC:'getUDPUdpClientByCenter closeUdp succeed:' + JSON.stringify(err)+this.oppositeIpPort, + // }) } }) } @@ -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/common/utils/tools.ts b/entry/src/main/ets/common/utils/tools.ts index 185efdc6..a7a0b831 100644 --- a/entry/src/main/ets/common/utils/tools.ts +++ b/entry/src/main/ets/common/utils/tools.ts @@ -4,6 +4,7 @@ import { expect } from '@ohos/hypium'; import FileUtil from './File'; export async function writeLog(path,param){ + return const fileUtil = new FileUtil(globalThis.context) const date=dateFormat(new Date).split(' ')[0] const folderPath = await fileUtil.initFolder(`/${path}/${date}`); diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index ac8f129b..100b00ed 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -9,6 +9,7 @@ import { getEsCarModel, } from '../common/service/initable'; import FileUtil from '../common/utils/File'; import { getUDP, getUDP2 } from '../common/utils/GlobalUdp'; import { initJudgeUdp } from '../common/utils/UdpJudge'; +import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; import { getliushuiNum, setliushuiNum, takePhotoFn, deleteAllFIleLog } from '../common/service/indexService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; @@ -143,6 +144,12 @@ struct Index { if (this.loading) { return } + if(judgeConfig.isTrajectoryOpen){ + router.pushUrl({ + url: 'pages/UserInfo', + }, router.RouterMode.Single) + return + } //判断数据库是否有表数据,有则直接跳转,没有则读取本地数据 getSyncData('MA_SYSSET').then(data => { console.log('datadata', JSON.stringify(data)) @@ -301,6 +308,9 @@ struct Index { if (this.loading) { return } + // let mode=globalThis.timeInfo?.mode?globalThis.timeInfo?.mode:1 + + // console.log('mode',mode) let workerInstance = new worker.ThreadWorker('entry/ets/workers/worker.ts'); const param = { carId: globalThis.carInfo?.carId, @@ -311,10 +321,9 @@ struct Index { mode: globalThis.timeInfo?.mode, context: this.context, host: globalThis.host, - centerHost: globalThis.timeInfo.url, + centerHost: globalThis.timeInfo?.url, singlePlay: globalThis.singlePlay } - console.log('globalThis.timeInfo', JSON.stringify(globalThis.timeInfo), 'globalThis.carInfo', JSON.stringify(globalThis.carInfo)) this.loading = true workerInstance.postMessage(param); workerInstance.onmessage = (e: MessageEvents): void => { @@ -412,15 +421,13 @@ struct Index { } async initParams() { - deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') + // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') //设置plc udp 同步requesthost await getUDP(this.context, false) this.loading = false console.log('globalThis.deviceNo000') - const data= await getDeviceInfo(this.context) - if(data==''){ - return - } + await getDeviceInfo(this.context) + await getCarInfo() await getUDP2(this.context, false) getTCP() diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 0452bf7f..75de1db4 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -124,7 +124,7 @@ struct UserInfo { console.log('响应头地址响应头地址') const mediaTest = new FilePhoto(this.context); this.filePhoto = new FilePhoto(this.context); - //语音功能 + //语音功能on new WebRTCVoice(this.context); //初始化数据 this.initData() @@ -435,10 +435,12 @@ struct UserInfo { //人脸比对窗口关闭 changeFaceCompareSuccess() { + this.ksksLimit = false console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser)) if (this.faceCompareSucess > 0) { //人脸比对通过 globalThis.statue = 4 + this.showFaceCompare = false this.sfbdinterfaceFn() } } @@ -600,7 +602,6 @@ struct UserInfo { this.stepFlag = true const carInfo = globalThis.carInfo; const {carId,examinationRoomId} = carInfo; - this.showFaceCompare = false let examItems = { getExaminationItemRsp: { body: { ykxx: '' } } }; if (!globalThis.singlePlay) { //获取已考项目 @@ -964,6 +965,7 @@ struct UserInfo { this.stopDeviceById() return } + console.log('this.FaceOpenStatuethis.FaceOpenStatue',this.FaceOpenStatue) if (this.FaceOpenStatue != '0') { this.showFaceCompare = true } else { diff --git a/entry/src/main/ets/pages/compontents/FaceCompare.ets b/entry/src/main/ets/pages/compontents/FaceCompare.ets index 79163903..26cfaf8e 100644 --- a/entry/src/main/ets/pages/compontents/FaceCompare.ets +++ b/entry/src/main/ets/pages/compontents/FaceCompare.ets @@ -107,7 +107,12 @@ export default struct FaceCompare { .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(async () => { this.times = 1; - + this.controller.stop() + this.vocObj && this.vocObj.releasePlayer() + this.showFaceCompare = !this.showFaceCompare + this.showFaceCompareFlag = !this.showFaceCompareFlag + this.faceCompareSucess = -1 + globalThis.statue = 2 }) } .width('88.9%') @@ -190,8 +195,8 @@ export default struct FaceCompare { verifyType: 1 }) .then(res => { - console.log('mmmmm8', res) - if (res) { + console.log('mmmmm8', JSON.stringify(res)) + if (res.imageCompareRsp.head.resultCode=='0') { this.controller.stop() this.showFaceCompare = !this.showFaceCompare this.showFaceCompareFlag = !this.showFaceCompareFlag