From 3fcdefeb4e86373668844f3a95b2d43932b715f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwangzhongjie=E2=80=9D?= Date: Fri, 23 Feb 2024 16:08:37 +0800 Subject: [PATCH 1/3] 222 --- entry/src/main/ets/pages/Index.ets | 3 ++- entry/src/main/ets/pages/compontents/judge/real-time.ets | 3 +++ entry/src/main/ets/pages/judgeSDK/api/index.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index e55c41e..9681974 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -12,7 +12,7 @@ import { getUDP, getUDP2 } from '../common/utils/GlobleUdp' import {initJudgeUdp} from '../common/utils/UdpJudge' import { getTCP } from '../common/utils/GlobleTcp' import TcpClient from '../common/utils/TcpClient'; - +import testNapi from '@ohos.hiserialsdk' import {setliushuiNum,getSingleCenterTable,getDoubleCeneterTable} from '../common/service/indexService' @Entry @Component @@ -226,6 +226,7 @@ struct Index { // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00] // globalThis.udpClientByTopLine.sendMsg(Array2Byte(arr).buffer) + console.info(testNapi) } async getModel() { const context = this.context; diff --git a/entry/src/main/ets/pages/compontents/judge/real-time.ets b/entry/src/main/ets/pages/compontents/judge/real-time.ets index 43dbc3b..397ecee 100644 --- a/entry/src/main/ets/pages/compontents/judge/real-time.ets +++ b/entry/src/main/ets/pages/compontents/judge/real-time.ets @@ -1,6 +1,8 @@ // @ts-nocheck import hilog from '@ohos.hilog'; import apiJudgeSdk from 'libJudgeSdk.so'; +// import apiJudgeSdk from '@ohos.judgesdk'; + import Judge from '../../judgeSDK/utils/judge-real' import {Project,ProjectObj,MarkRule} from '../../judgeSDK/api/judgeSDK.d' import common from '@ohos.app.ability.common'; @@ -37,6 +39,7 @@ struct RealTime { id: 'duolun_plugin_id_draw', //显示轨迹窗口id名称,注意这个ID要和C++侧一致,不能变 type: 'surface', libraryname: 'JudgeSdk' + // libraryname: 'judgesdk' }) .width(this.width) .height(this.height) diff --git a/entry/src/main/ets/pages/judgeSDK/api/index.ts b/entry/src/main/ets/pages/judgeSDK/api/index.ts index d278e3a..27cddcc 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/index.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/index.ts @@ -1,5 +1,5 @@ import libJudgeSdk from 'libJudgeSdk.so' - +// import libJudgeSdk from '@ohos.judgesdk' /** * 苏仁君 * @date 2023/04/10 From 0fe5385625ad6e347a33d1a2b0c1cdc9030df82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwangzhongjie=E2=80=9D?= Date: Mon, 26 Feb 2024 15:01:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9C=80=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/database/Rdb.ts | 4 +- .../main/ets/common/service/indexService.ts | 12 +- entry/src/main/ets/common/service/initable.ts | 15 +- .../ets/common/service/terminalService.ts | 2 +- .../main/ets/common/service/videoService.ts | 154 ++- entry/src/main/ets/common/utils/GlobleUdp.ts | 27 +- .../ets/common/utils/UdpClientByCenter.ts | 8 +- entry/src/main/ets/pages/ExaminerLogin.ets | 206 ++-- entry/src/main/ets/pages/Index.ets | 5 +- entry/src/main/ets/pages/Settings.ets | 4 +- entry/src/main/ets/pages/TeminalInfos.ets | 191 ++++ entry/src/main/ets/pages/UserInfo.ets | 37 +- entry/src/main/ets/pages/VideoConfig.ets | 901 ++++-------------- .../compontents/faceCompareByhaikang.ets | 471 +++------ .../src/main/ets/pages/judgeSDK/api/index.ts | 1 + .../main/ets/pages/judgeSDK/dataTest/index.ts | 1 + entry/src/main/ets/pages/judgeSDK/judge.ts | 18 +- .../ets/pages/judgeSDK/utils/judge-real.ts | 8 - entry/src/main/ets/pages/register.ets | 4 +- 19 files changed, 732 insertions(+), 1337 deletions(-) create mode 100644 entry/src/main/ets/pages/TeminalInfos.ets diff --git a/entry/src/main/ets/common/database/Rdb.ts b/entry/src/main/ets/common/database/Rdb.ts index b10d079..b02b140 100644 --- a/entry/src/main/ets/common/database/Rdb.ts +++ b/entry/src/main/ets/common/database/Rdb.ts @@ -162,11 +162,11 @@ export default class Rdb { callback(ret); }); } - sqlOperate(str,name,callback) { + async sqlOperate(str,name,callback) { this.rdbStore.executeSql(str,(err)=>{ if (err) { - callback(false) console.info("ExecuteSql failed, err: "+name + JSON.stringify(err)) + callback(false) return } console.log('ExecuteSqlsuccess') diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index 0f84744..beb0e3f 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -101,20 +101,16 @@ export async function getDoubleCeneterTable() { //单中心存表 export async function getSingleCenterTable() { return new Promise((reslove,reject)=>{ - upDataZhongxinginitialization().then((flag)=>{ - if(flag){ + upDataZhongxinginitialization().then((result)=>{ + if(result){ router.pushUrl({ url: 'pages/ExaminerLogin', }, router.RouterMode.Single) reslove(true) }else{ - // router.pushUrl({ - // url: 'pages/ExaminerLogin', - // }, router.RouterMode.Single) - // reslove(true) promptAction.showToast({ - message: '联网更新失败,请检查网络后重新更新', - duration: 1000 + message: `联网更新失败,请检查网络后重新更新`, + duration: 500 }); reslove(false) } diff --git a/entry/src/main/ets/common/service/initable.ts b/entry/src/main/ets/common/service/initable.ts index dd13317..a3128fe 100644 --- a/entry/src/main/ets/common/service/initable.ts +++ b/entry/src/main/ets/common/service/initable.ts @@ -73,6 +73,7 @@ const centerToMap={ 't_carparmset':MA_T_CARPARMSET, // 'ES_CAR_VIDEO_PARAMETER':ES_CAR_VIDE0pO_PARAMETER } + function sqlInsertCommonFn(tableName,resultArr){ return new Promise((resolve,reject)=>{ const accountTable = new AccountTable(() => { @@ -138,6 +139,7 @@ function sqlInsertCommonFn(tableName,resultArr){ }); }) } + export async function getDataBaseTable(params) { return new Promise((resolve, reject) => { const accountTable = new AccountTable(() => { @@ -199,7 +201,11 @@ export async function getDataBaseTable(params) { }); }) } - +//依据数组和表名更新sql表 +export async function upDateTableByArray(tableName,arr) { + sqlInsertCommonFn(tableName,arr) +} +//更新双中心表 export async function upDateTable(params) { return new Promise((resolve, reject) => { const date = new Date() @@ -237,11 +243,6 @@ export async function upDateTable(params) { }); } - -// -export async function upDateTableConfig(tableName,arr) { - sqlInsertCommonFn(tableName,arr) -} //考试平台 export async function getMySystemSetTable(params) { return new Promise((resolve, reject) => { @@ -276,6 +277,7 @@ export async function getMySystemSetTable(params) { } +//依据表名同步获取数据 export async function getSyncData(tableName) { return new Promise((resolve, reject) => { const accountTable = new AccountTable(() => { @@ -288,6 +290,7 @@ export async function getSyncData(tableName) { }) } + export async function delSyncTable(tableName){ return new Promise((resolve,reject)=>{ const accountTable = new AccountTable(() => { diff --git a/entry/src/main/ets/common/service/terminalService.ts b/entry/src/main/ets/common/service/terminalService.ts index 0aefc50..93e8ec7 100644 --- a/entry/src/main/ets/common/service/terminalService.ts +++ b/entry/src/main/ets/common/service/terminalService.ts @@ -4,7 +4,7 @@ import { dateFormat} from '../utils/tools' //获取设备信息 export async function getDeviceInfo() { - globalThis.deviceNo = 'J43405J003101'; //设备mac + // globalThis.deviceNo = 'J43405J003101'; //设备mac globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac globalThis.diskId = '1231231231'; //硬盘号 globalThis.hasAuth = true; diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index ee807e3..e79824a 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -3,55 +3,43 @@ import onvifclient from '@ohos.onvifclient'; import fs from '@ohos.file.fs' import util from '@ohos.util'; import configAddress from '../../common/utils/FileConfig' -import {getCurrentTime} from '../utils/tools' +import { getCurrentTime } from '../utils/tools' +import record from '@ohos.rtsprecord'; + +const rtsp_server = record.createServer(); //开始录屏 -export async function startRecordVideo(param,td,context) { - return new Promise(async (reslove,reject)=>{ +export async function startRecordVideo(param, td, context, dir) { + return new Promise((reslove, reject) => { var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`; - // var result3 = onvifclient.startRecordVideo(video_uri, "video/" ); - // const record_handle = result3.dataInt; - // console.info( `baoyihu startRecordVideo result:`+result3.result+ ` VideoFile:`+result3.dataString ); - // reslove(record_handle) - // return - var mediaTest = mediaLibrary.getMediaLibrary(context); - let mediaType = mediaLibrary.MediaType.VIDEO; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; - const num = Math.floor(Math.random() * 10000) - const name = `movie_record${getCurrentTime(1)}.mp4` - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - mediaTest.createAsset(mediaType, name, path, (error, asset) => { - const file_asset = asset; // 记录 ,关闭时用到 - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = configAddress.videoSavePath + name; - var result = onvifclient.startRecordVideo(video_uri, file_path, fd); - var rocord_handle = result.dataInt; // 记录 ,关闭时用到 - reslove({fd,rocord_handle,file_asset}) - } else { - reslove({fd:0,rocord_handle:0,file_asset:0}) - console.error('baoyihu startRecordVideo File Open failed with error: ' + error); - } - }); - }); + if (rtsp_server != null) { + console.log(`Rtsprecord startRecordVideo begin`); + var recordResult = rtsp_server.startRecordVideo(context, video_uri, dir); + const handleId = recordResult.dataInt; + reslove(handleId) + console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt); + } + else { + console.log(`Rtsprecord startRecordVideo rtsp_server isnull`); + reslove(0) + } + console.log(`Rtsprecord startRecordVideo end`); }) } //结束录屏 export async function endRecordVideo(record_handle) { - if(this.record_handle >0) - { - var result = onvifclient.endRecordVideo(record_handle); - // this.record_handle = -1; - console.info( `baoyihu endRecordVideo result:`+result.result+ ` VideoFile:`+result.dataString ); + if (rtsp_server != null && record_handle > 0) { + console.log(`Rtsprecord endRecordVideo begin`); + var recordResult = rtsp_server.endRecordVideo(record_handle); + console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt + ` filename:` + recordResult.fileName); } - else - { - console.info( `baoyihu endRecordVideo no task error`); + else { + console.log(`Rtsprecord endRecordVideo handleId isnull`); } - // var result = onvifclient.endRecordVideo(filehandle); - // fs.closeSync(filehandle); - // file_asset.close(filehandle); + // var result = onvifclient.endRecordVideo(record_handle); + // fs.closeSync(record_handle); + // file_asset.close(record_handle); } /** @@ -60,65 +48,49 @@ export async function endRecordVideo(record_handle) { * @param context * @param type=0不获取base64 */ -export async function takePhoto(param,context,type=0) { - return new Promise(async (reslove,reject)=>{ +export async function takePhoto(param, context, type = 0, dir) { + return new Promise((reslove, reject) => { var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`; - - var mediaTest = mediaLibrary.getMediaLibrary(context); - let mediaType = mediaLibrary.MediaType.IMAGE; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE; - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - const name="picture_record" + getCurrentTime(1) + ".jpg" - // if(type==1){ - // var result = onvifclient.getVideoSnapshot(video_uri,"") - // reslove(result.dataString) - // }else{ - // var result = onvifclient.getVideoSnapshot(video_uri,"") - // reslove('') - // } - // return - mediaTest.createAsset(mediaType, name, path, (error, asset) => { - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path =configAddress.picSavePath + name - // var result3 = onvifclient.getVideoSnapshot(video_uri,""); - var result3 = onvifclient.getVideoSnapshot(video_uri, file_path, fd); - fs.closeSync(fd); - asset.close(fd); - if(type==1){ - fs.lstat(file_path).then((stat) => { - let file = fs.openSync(file_path, fs.OpenMode.READ_WRITE); - const size = Number(stat.size) + 100 - let buf = new ArrayBuffer(size); - let num = fs.readSync(file.fd, buf); - var that = new util.Base64(); - var array = new Uint8Array(buf); - var result = that.encodeToStringSync(array); //base64圖片 - mediaTest.deleteAsset(file_path).then(() => { - console.log('delSuccess') - }).catch(() => { - console.log('delError') - }) - this.fileUtil.deleteF(file_path, 3) - reslove(result) - }).catch((err) => { - console.info("get link status failed with error message: " + err.message + ", error code: " + err.code); - }); - }else{ - reslove('') - } - } else { - console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error); - } - }); - }); + var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, dir); + console.log(`baoyihu Rtsprecord getVideoSnapshot file:` + snapResult.dataString); + if (type == 1) { + reslove(snapResult.dataString) + } else { + reslove('') + } }) } +export async function deleteAllFile(dir,context) { + const mediaType = mediaLibrary.MediaType.IMAGE + var mymediaLib = await mediaLibrary.getMediaLibrary(context); + let fetchOp = { selections: `media_type =? `, selectionArgs: [`${mediaType}`] } + console.info(`baoyihu deleteRecordFile fetchOp:` + fetchOp); + var asset = await mymediaLib.getFileAssets(fetchOp); + if (mediaType == mediaLibrary.MediaType.IMAGE) { + var base_Dir = "/storage/media/100/local/files/Pictures/"; + } + else { + var base_Dir = "/storage/media/100/local/files/Videos/"; + } + + var my_dir = dir; + asset.getAllObject((eer, fileArray) => { + for (let onfile of fileArray) { + var delet_dir = base_Dir + my_dir + onfile.uri + console.info(`baoyihu deleteRecordFile uri:` + delet_dir); + mymediaLib.deleteAsset(delet_dir, (error, asset) => { + console.info(`baoyihu deleteRecordFile 3 error:` + error); + }); + } + }); + console.log(`Rtsprecord getVideoSnapshot end:`); +} + export interface videoPlayRes { rocord_handle?: number; fd?: number; - file_asset?:any + file_asset?: any } diff --git a/entry/src/main/ets/common/utils/GlobleUdp.ts b/entry/src/main/ets/common/utils/GlobleUdp.ts index 1ae677a..328448f 100644 --- a/entry/src/main/ets/common/utils/GlobleUdp.ts +++ b/entry/src/main/ets/common/utils/GlobleUdp.ts @@ -14,12 +14,9 @@ export async function getUDP() { if(result.length){ if(globalThis.udpClient&&globalThis.udpClient.closeUdp){ globalThis.udpClient.closeUdp(()=>{ - + // const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800','192.168.36.9','11111')//杭州 globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort) - globalThis.udpClient.sendMsg('111') - - // globalThis.udpClient = udpClient }) }else{ @@ -42,48 +39,31 @@ export async function getUDP2() { if(result.length){ if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){ globalThis.udpClient2.closeUdp(async ()=>{ - // globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800','112.80.35.83','11056') + // const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800','192.168.36.9','11111')//杭州 globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort) - // globalThis.udpClient2.rebindUdp(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) - // globalThis.udpClient2.rebindUdp(result[0].udplocalIp, result[0].udpLocalIpByGPS,result[0].udpOppositeIp,result[0].udpOppositeIpPortByGPS) globalThis.udpClient2.onMessage((val)=>{ // globalThis.udpClnt2.sendMsg(heartMsg(context)) }) }) }else{ - // const udpClient: UdpClient =new UdpClient(result[0].udplocalIp, result[0].udpLocalIpByGPS,result[0].udpOppositeIp,result[0].udpOppositeIpPortByGPS) const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort) - // const udpClient: UdpClientByCenter =new UdpClientByCenter(result[0].udplocalIp, '8800','112.80.35.83','11056') - // const udpClient: UdpClient =new UdpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) - globalThis.udpClient2 = udpClient globalThis.udpClient2.bindUdp() - - // globalThis.udpClient2.sendMsg(heartMsg(context)) - globalThis.udpClient2.onMessage((val)=>{ if(val.id=='32'){ globalThis.signNum=val.body[1] }else if(val.id=='46'){ - let tmpList = [] console.log('lsh',globalThis.lsh) const str = globalThis.lsh for (let i = 0;i < str.length; i++) { tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } - const param = { id: 47, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId } globalThis.udpClient2.send(param) } - - // setTimeout(async ()=>{ - // - // globalThis.udpClient2.sendMsg(heartMsg(context)) - // - // },1000) }) } }else{ @@ -98,7 +78,6 @@ export async function setTopLineUdp(){ if(config && config[0] && config[0].udplocalIp){ const {udplocalIp,udpOppositeIp,udpOppositeIpPort} = config[0]; const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '55509',udpOppositeIp,udpOppositeIpPort) - // const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8800','192.168.36.4','33333') udpClient.bindUdp() return { @@ -114,7 +93,7 @@ export async function setJudgeUdp(){ const config = await getSyncData('IpConfigTable'); if(config && config[0] && config[0].udplocalIp){ const {udplocalIp} = config[0]; - // const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080','192.168.32.167','33333') + // const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080','192.168.36.9','33333') const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8080',globalThis.carInfo?.gpsAddress,globalThis.carInfo?.hintPort) // const udpClient: UdpClientByCenter = new UdpClientByCenter(udplocalIp, '8800','192.168.36.4','33333') udpClient.bindUdp() diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index 69e269c..6e9ccb9 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -167,7 +167,6 @@ export default class UdpClientByCenter { this.context=context } this.sendId=param.id - console.log('sendMsg',JSON.stringify(param)) const msgData=this.setWholeMsg(param) // const msgData=this.setMsyBody('31','010000000000000') let promise = this.udp.send({ @@ -179,9 +178,12 @@ export default class UdpClientByCenter { }); this.stashFn=param.callback?param.callback:()=>{} promise.then(() => { - if(this.sendId=='46'&¶m.callback){ - param.callback() + if(param.sendCallback){ + param.sendCallback() } + // if(this.sendId=='46'&¶m.callback){ + // param.callback() + // } console.log(`${TAG} udp send success:`); }).catch(err => { console.log(`${TAG} udp send fail:${JSON.stringify(err)}`); diff --git a/entry/src/main/ets/pages/ExaminerLogin.ets b/entry/src/main/ets/pages/ExaminerLogin.ets index 55589ec..c599d34 100644 --- a/entry/src/main/ets/pages/ExaminerLogin.ets +++ b/entry/src/main/ets/pages/ExaminerLogin.ets @@ -2,8 +2,7 @@ import router from '@ohos.router' import TopLogo from './compontents/topLogo' import { examinerLoginService } from '../common/service/ExaminerService' import Md5 from '../common/utils/md5'; -import prompt from '@ohos.prompt' -import { voiceService } from '../common/service/voiceService' +import promptAction from '@ohos.promptAction' @Entry @Component @@ -17,127 +16,118 @@ struct Index { @State @Watch('outClick') outFlag: boolean = false; private vocObj = null; build() { + Column() { + TopLogo({outFlag:$outFlag}) Column() { - TopLogo({outFlag:$outFlag}) + Text('请考官输入用户名密码').fontColor('#FFAD33').fontSize(36*this.ratio) + Row() { + ForEach(this.inputPlaceholderArr, (item:any, index:number) => { + Row(){ + TextInput({ placeholder: `${item}`,text: this.inputTextArr[index] }) + .fontSize(42*this.ratio) + .fontColor('white') + .placeholderFont({ size: 42*this.ratio }) + .placeholderColor('gray') + .caretColor('white') + .backgroundColor('transparent') + .width('90%') + .margin({left: '4%'}) + .type(index === 0 ? InputType.Normal : InputType.Password) + .focusable(false) + .onClick(() => { + this.currentInputIndex = index; + }) + } + .backgroundImage(this.currentInputIndex == index ? $r('app.media.kuang_pre') : $r('app.media.kuang_nor')) + .backgroundImageSize({width:'100%',height:'100%'}) + .width('48%') + .height('14.9%') + }) + } + .width('90%') + .margin({top: 25*this.ratio}) //20 + .justifyContent(FlexAlign.SpaceBetween) Column() { - Text('请考官输入用户名密码').fontColor('#FFAD33').fontSize(36*this.ratio) - Row() { - ForEach(this.inputPlaceholderArr, (item:any, index:number) => { - Row(){ - TextInput({ placeholder: `${item}`,text: this.inputTextArr[index] }) - .fontSize(42*this.ratio) - .fontColor('white') - .placeholderFont({ size: 42*this.ratio }) - .placeholderColor('gray') - .caretColor('white') - .backgroundColor('transparent') - .width('90%') - .margin({left: '4%'}) - .type(index === 0 ? InputType.Normal : InputType.Password) - .focusable(false) - .onClick(() => { - this.currentInputIndex = index; - }) - } - .backgroundImage(this.currentInputIndex == index ? $r('app.media.kuang_pre') : $r('app.media.kuang_nor')) - .backgroundImageSize({width:'100%',height:'100%'}) - .width('48%') - .height('14.9%') - }) - } - .width('90%') - .margin({top: 25*this.ratio}) //20 - .justifyContent(FlexAlign.SpaceBetween) - Column() { - Flex({wrap: FlexWrap.Wrap, - justifyContent:FlexAlign.SpaceAround, - alignContent: FlexAlign.SpaceAround}) { - ForEach(this.imgArr1, (item:Resource, index:number) => { - if(index === this.imgArr1.length -1 ) { - Image(item).width('38%').height('24%').onClick(() => { + Flex({wrap: FlexWrap.Wrap, + justifyContent:FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround}) { + ForEach(this.imgArr1, (item:Resource, index:number) => { + if(index === this.imgArr1.length -1 ) { + Image(item).width('38%').height('24%').onClick(() => { - if(this.inputTextArr[0].trim()==''||this.inputTextArr[1].trim()==''){ - prompt.showToast({ - message: '请输入用户名和密码', - duration: 3000 - }); - return - } + if(this.inputTextArr[0].trim()==''||this.inputTextArr[1].trim()==''){ + promptAction.showToast({ + message: '请输入用户名和密码', + duration: 3000 + }); + return + } - const param = { - carId: globalThis.carInfo.carId, - examinationRoomId: globalThis.carInfo.examinationRoomId, - username: this.inputTextArr[0], - password: Md5.Instance.get_md5(this.inputTextArr[1]) - } - console.log('paramparam',JSON.stringify(globalThis.carInfo)) - examinerLoginService(param).then(res => { - // this.vocObj.playAudio({ - // type: 1, - // name: 'media_button.wav' - // }) - // this.url='pages/userInfo' - router.pushUrl({ - url: 'pages/UserInfo', - },router.RouterMode.Single); - console.log('res11',JSON.stringify(res)) - globalThis.username=this.inputTextArr[0] - }) - }) - }else { - Image(item).width('18%').height('24%').onClick(() => { + const param = { + carId: globalThis.carInfo.carId, + examinationRoomId: globalThis.carInfo.examinationRoomId, + username: this.inputTextArr[0], + password: Md5.Instance.get_md5(this.inputTextArr[1]) + } + console.log('paramparam',JSON.stringify(globalThis.carInfo)) + examinerLoginService(param).then(res => { // this.vocObj.playAudio({ // type: 1, // name: 'media_button.wav' // }) - this.url='' - if(index < 9) { - this.inputTextArr[this.currentInputIndex] += (index + 1).toString() - }else { - if(index === 9) { - this.inputTextArr[this.currentInputIndex] += (0).toString() - } if(index === 10) { - this.inputTextArr[this.currentInputIndex] += 'X'; - } else if(index === 11) { - this.inputTextArr[this.currentInputIndex] = ''; - } if(index === 12) { - this.inputTextArr[this.currentInputIndex] = this.inputTextArr[this.currentInputIndex].slice(0, -1) - } - } - console.log(this.inputTextArr[this.currentInputIndex]) + // this.url='pages/userInfo' + router.pushUrl({ + url: 'pages/UserInfo', + },router.RouterMode.Single); + console.log('res11',JSON.stringify(res)) + globalThis.username=this.inputTextArr[0] }) - } - }) - } - .height('100%') + }) + }else { + Image(item).width('18%').height('24%').onClick(() => { + // this.vocObj.playAudio({ + // type: 1, + // name: 'media_button.wav' + // }) + this.url='' + if(index < 9) { + this.inputTextArr[this.currentInputIndex] += (index + 1).toString() + }else { + if(index === 9) { + this.inputTextArr[this.currentInputIndex] += (0).toString() + } if(index === 10) { + this.inputTextArr[this.currentInputIndex] += 'X'; + } else if(index === 11) { + this.inputTextArr[this.currentInputIndex] = ''; + } if(index === 12) { + this.inputTextArr[this.currentInputIndex] = this.inputTextArr[this.currentInputIndex].slice(0, -1) + } + } + console.log(this.inputTextArr[this.currentInputIndex]) + }) + } + }) } - .margin({top: 20*this.ratio}) - .width('90%') - .height('62.7%') - .backgroundColor('#E5E3DF') - .borderRadius(20*this.ratio) + .height('100%') } - .margin({top: -10*this.ratio}) - .justifyContent(FlexAlign.SpaceAround) + .margin({top: 20*this.ratio}) + .width('90%') + .height('62.7%') + .backgroundColor('#E5E3DF') + .borderRadius(20*this.ratio) } - .width('100%') - .height('100%') - .justifyContent(FlexAlign.SpaceBetween) - .backgroundImagePosition({x: 0, y: 0}) - .backgroundImage($r('app.media.index_bg')) - .backgroundImageSize({ width: '100%', height: '100%' }) + .margin({top: -10*this.ratio}) + .justifyContent(FlexAlign.SpaceAround) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .backgroundImagePosition({x: 0, y: 0}) + .backgroundImage($r('app.media.index_bg')) + .backgroundImageSize({ width: '100%', height: '100%' }) } aboutToAppear() { this.url='' - // this.vocObj = new voiceService(async (status,val) => { - // if (status == 'idle') { - // if(this.url=='pages/userInfo'){ - // router.pushUrl({ - // url: this.url, - // }); - // } - // } - // }); console.info('ExmainerLogin aboutToAppear'); } onPageShow() { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 9681974..86168f7 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -175,7 +175,7 @@ struct Index { this.loading = false } - async heartMsg(context) { + async heartMsg() { const arr = [globalThis.signNum||0, globalThis.statue||1] let tmpList = []; tmpList.push(string2Bytes(arr[0], 1 * 8)[0]) @@ -185,10 +185,7 @@ struct Index { tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId} - - globalThis.udpClient2.sendMsg(param, this.context) - } onPageShow() { diff --git a/entry/src/main/ets/pages/Settings.ets b/entry/src/main/ets/pages/Settings.ets index 1a80fbd..5431a5d 100644 --- a/entry/src/main/ets/pages/Settings.ets +++ b/entry/src/main/ets/pages/Settings.ets @@ -18,13 +18,13 @@ struct Index { Column() { Row() { Image($r('app.media.setting_clzc')).width('30.5%').height('74%').onClick(()=>{ - this.url='pages/register' + this.url='pages/Register' router.pushUrl({ url: this.url, },router.RouterMode.Single); }) Image($r('app.media.setting_spjk')).width('30.5%').height('74%').onClick(()=>{ - this.url='pages/videoConfig' + this.url='pages/VideoConfig' router.pushUrl({ url: this.url, },router.RouterMode.Single); diff --git a/entry/src/main/ets/pages/TeminalInfos.ets b/entry/src/main/ets/pages/TeminalInfos.ets new file mode 100644 index 0000000..868f493 --- /dev/null +++ b/entry/src/main/ets/pages/TeminalInfos.ets @@ -0,0 +1,191 @@ +import router from '@ohos.router' +import TopLogo from './compontents/topLogo' +import ethernet from '@ohos.net.ethernet'; +import prompt from '@ohos.prompt' +import { upDateTableByArray} from '../common/service/initable' +import { getSyncData} from '../common/service/initable' +import { voiceService } from '../common/service/voiceService' + +@Entry +@Component +struct Index { + @State textList1: string[] = ['ftp服务器IP:','响应端口','前置机IP','响应端口', '子网掩码','默认网关','用户名:', '密码:','dns','差分服务器IP: ', '响应端口:',] + @State textList2: string[] = ['后置机IP:','响应端口:', '本地端口:'] + @State ratio: number = 850 / 960 + @State inputFontSize:number=12 //12 + // + @State inputTextList1: string[] = ['192.168.36.2','8083','192.168.36.92','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.203','8000',] + @State inputTextList2: string[] = ['192.168.36.91','20022'] + // 112.80.35.83 11052 + // @State inputTextList1: string[] = ['192.168.7.254','8084','192.168.7.170','20122','255.255.255.0','192.168.7.1','','','114.114.114.114','112.80.35.83','11052'] + // @State inputTextList2: string[] = ['192.168.7.124','20022'] + + + @State @Watch('outClick') outFlag: boolean = false; + private vocObj = null; + scroller: Scroller = new Scroller() + build() { + Column() { + TopLogo({outFlag:$outFlag}) + Column() { + Column() { + Scroll(this.scroller){ + Flex({'wrap':FlexWrap.Wrap}) { + ForEach(this.textList1, (item:string, index:number) => { + Row() { + Text(item) + .width('40%') + .height('100%') + .fontColor('#E5CBA1') + .padding({'left': '35px'}) + .fontSize(this.inputFontSize*this.ratio) + TextInput({'text':this.inputTextList1[index]?this.inputTextList1[index]: ''}) + .width('50%') + .height('60%') + .fontColor('#fff') + .borderColor('#E6E0D8') + .borderRadius('10px') + .borderWidth('2px') + .fontSize(this.inputFontSize*this.ratio) + .padding({top:0,bottom:0}) + .linearGradient({ + angle: 0, + colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]] + }).onChange((value: string) => { + this.inputTextList1[index]=value + + }) + } + .width('50%') + .height('16.7%') + }) + ForEach(this.textList2, (item:string, index:number) => { + Row() { + Text(item) + .width('40%') + .height('100%') + .fontColor('#E5CBA1') + .fontSize(this.inputFontSize*this.ratio) + .padding({'left': '35px'}) + TextInput({'text':this.inputTextList2[index]?this.inputTextList2[index]: ''}) + .width('60%') + .height('60%') + .fontColor('#fff') + .borderColor('#E6E0D8') + .borderRadius('10px') + .borderWidth('2px') + .padding({top:0,bottom:0}) + .fontSize(this.inputFontSize*this.ratio) + .linearGradient({ + angle: 0, + colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]] + }) + .onChange((value: string) => { + this.inputTextList2[index]=value + + }) + } + .width('32.5%') + .height('16.7%') + }) + } + } + .width('95%') + .height('90%') + .margin({'top': '2%'}) + .backgroundColor('#282828') + .borderRadius('15px') + } + .width('100%') + .height('80%') + .borderRadius('25px') + Column() { + Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(()=>{ + upDateTableByArray('IpConfigTable',[{udplocalIp:this.inputTextList1[2],udplocalIpPort:this.inputTextList1[3],udpOppositeIp:this.inputTextList2[0],udpOppositeIpPort:this.inputTextList2[1],tcplocalIp:this.inputTextList1[0],tcplocalIpPort:this.inputTextList1[1],tcpOppositeIp:this.inputTextList1[9],tcpOppositePort:this.inputTextList1[10],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[8]}]) + ethernet.setIfaceConfig("eth0", { + mode: 0, + ipAddr:this.inputTextList1[2], + route: "0.0.0.0", + gateway: this.inputTextList1[5],//value.gateway网关 + netMask: this.inputTextList1[4],//value.netMask网络掩码 + dnsServers: this.inputTextList1[8], + // domain: "" + }, (error) => { + if (error) { + prompt.showToast({ + message: '设置失败'+JSON.stringify(error), + duration: 3000 + }); + } else { + prompt.showToast({ + message: '设置成功', + duration: 3000 + }); + } + }); + }) + } + .backgroundColor('#CCC4B8') + .width('100%') + .height('20%') + .borderRadius({'bottomLeft':'25px','bottomRight':'25px'}) + .justifyContent(FlexAlign.SpaceAround) + } + .width('75%') + .height('69.4%') + .backgroundColor('#E6E3DF') + .borderRadius('25px') + .margin({'top':'7%'}) + .justifyContent(FlexAlign.SpaceAround) + + } + .width('100%') + .height('100%') + .backgroundImagePosition({x: 0, y: 0}) + .backgroundImage($r('app.media.index_bg')) + .backgroundImageSize({ width: '100%', height: '100%' }) + } + aboutToAppear() { + getSyncData('IpConfigTable').then((result:Array)=>{ + console.log('result222',JSON.stringify(result)) + if(result.length){ + console.log('tagtag',JSON.stringify(result)) + this.inputTextList1[2]=result[0].udplocalIp + this.inputTextList1[3]=result[0].udplocalIpPort + this.inputTextList2[0]=result[0].udpOppositeIp + this.inputTextList2[1]=result[0].udpOppositeIpPort + + this.inputTextList1[0]=result[0].tcplocalIp + this.inputTextList1[1]=result[0].tcplocalIpPort + this.inputTextList1[9]=result[0].tcpOppositeIp + this.inputTextList1[10]=result[0].tcpOppositePort + this.inputTextList1[5]=result[0].gateway + this.inputTextList1[4]=result[0].netMask + this.inputTextList1[8]=result[0].dnsServers + this.inputTextList1[11]=result[0].centerIp + this.inputTextList1[12]=result[0].heartPort + this.inputTextList1[13]=result[0].gpsPort + } + }) + ethernet.getIfaceConfig("eth0", (error, value) => { + if (error) { + // that.errorMsg='error' + console.log("boot_up getIp_new callback error = " + JSON.stringify(error)); + } else { + console.log("boot_up getIp_new callback ipAddr = " + JSON.stringify(value.ipAddr)); // + console.log(" boot_up getIp_new callback mode = " + JSON.stringify(value.mode)); + console.log("boot_up getIp_new callback route = " + JSON.stringify(value.route)); + console.log("boot_up getIp_new callback gateway = " + JSON.stringify(value.gateway)); + console.log("boot_up getIp_new callback netMask = " + JSON.stringify(value.netMask)); + console.log("boot_up getIp_new callback dnsServers = " + JSON.stringify(value.dnsServers)); + } + }) + + } + onPageShow() { + console.info('Index onPageShow'); + } + outClick(){ + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 6b043fe..52d8993 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -76,6 +76,7 @@ struct UserInfo { @State numCount: number = 0; @State signNum: number = 0; @State isCanClick: boolean = true; + @State FaceOpenStatue: string = '0';//是否开启人脸识别 subscriber; @State faceCatchImg: string = '' @@ -88,19 +89,7 @@ struct UserInfo { //身份证读卡器初始化 this.openDeviceByIDCard() // 如果是单机模式则模拟假数据 - if (globalThis.singlePlay) { - // TODO 模拟假数据 - this.list = CandidateData - this.pageIndex = 0 - this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) - this.currentUser = this.dataList[0] - this.lsh = this.currentUser.lsh - globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm - globalThis.lsh = this.lsh - return - } else { - // this.getExaminationStudentInfoFn() - } + this.initSysset() initJudgeUdp() this.interval=setInterval(()=>{ @@ -219,6 +208,19 @@ struct UserInfo { this.currentUser = EmptyCandidateObject globalThis.statue = 2 this.numCount = 0 + if (globalThis.singlePlay) { + // TODO 模拟假数据 + this.list = CandidateData + this.pageIndex = 0 + this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) + this.currentUser = this.dataList[0] + this.lsh = this.currentUser.lsh + globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm + globalThis.lsh = this.lsh + return + } else { + // this.getExaminationStudentInfoFn() + } } async heartMsg() { @@ -275,6 +277,9 @@ 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 faceParam = syssetParams.filter(sys => sys.v_no === '17') + that.FaceOpenStatue = faceParam?.[0]?.v_value || '0' + console.log('mmmmm',that.FaceOpenStatue) //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 if (that.studentRefreshStatue == '2') { clearInterval(that.interval2) @@ -657,7 +662,11 @@ struct UserInfo { }) return } - this.showFaceCompare = true + if(this.FaceOpenStatue!='0'){ + this.showFaceCompare = true + }else{ + this.sfbdinterfaceFn() + } }) } } diff --git a/entry/src/main/ets/pages/VideoConfig.ets b/entry/src/main/ets/pages/VideoConfig.ets index 5b0623e..b5e8ab8 100644 --- a/entry/src/main/ets/pages/VideoConfig.ets +++ b/entry/src/main/ets/pages/VideoConfig.ets @@ -1,15 +1,10 @@ import TopLogo from './compontents/topLogo' import FileUtil from '../common/utils/File' -import { SourceType } from '@ohos.multimodalInput.touchEvent' import { VideoConfig } from './interfaces' import common from '@ohos.app.ability.common'; -import router from '@ohos.router' -import onvifclient from '@ohos.onvifclient'; -import fs from '@ohos.file.fs' -import prompt from '@ohos.prompt' -import mediaLibrary from '@ohos.multimedia.mediaLibrary' -// import { voiceService } from '../common/service/voiceService' - +import promptAction from '@ohos.promptAction' +import { startRecordVideo, endRecordVideo,takePhoto } from '../common/service/videoService' +import configAddress from '../common/utils/FileConfig' @Entry @Component struct Index { @@ -17,28 +12,21 @@ struct Index { @State videoSrc: string = 'rtsp://admin:12345qwe@192.168.36.94:554/h264/ch3/main/av_stream' @State previewUri: Resource = $r('app.media.2_nor') @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X - @State inputFontSize:number=10 //12 - @State rocord_handle1: number = 0 - @State rocord_handle2: number = 0 - @State rocord_handle3: number = 0 - @State rocord_handle4: number = 0 - @State filehandle1: number = 0 - @State filehandle2: number = 0 - @State filehandle3: number = 0 - @State filehandle4: number = 0 - @State file_asset1: any = 0 - @State file_asset2: any = 0 - @State file_asset3: any = 0 - @State file_asset4: any = 0 - // file_handle1 + @State inputFontSize: number = 10 //12 + @State rocordHandleObj:any = { + rocord_handle1:0, + rocord_handle2:0, + rocord_handle3:0, + rocord_handle4:0 + } @State isAutoPlay: boolean = true @State showFlag: boolean = false - @State videoNum: string = '1' private vocObj = null; @State showControls: boolean = false private fileUtil: FileUtil @State @Watch('outClick') outFlag: boolean = false; @State oldParam: VideoConfig = { + videoNum:'1', spls: '1', wz: '0,0', faceFlag: false, @@ -65,6 +53,7 @@ struct Index { rlls: '1' } @State param: VideoConfig = { + videoNum:'1', spls: '1', wz: '0,0', faceFlag: false, @@ -90,286 +79,131 @@ struct Index { fontSize: '', rlls: '1' } - @State openFlag:boolean=true + @State openFlag: boolean = true + @State lsArr: Array = [ + {key:'第一路'}, + {key:'第二路'}, + {key:'第三路'}, + {key:'第四路'}, + ] + private context = getContext(this) as common.UIAbilityContext; private controller1: VideoController = new VideoController() private controller2: VideoController = new VideoController() private controller3: VideoController = new VideoController() private controller4: VideoController = new VideoController() + @State videoArr: Array = [ + {td:'td1',controller:this.controller1}, + {td:'td2',controller:this.controller2}, + {td:'td3',controller:this.controller3}, + {td:'td4',controller:this.controller4}, + ] private inputController: TextInputController = new TextInputController() - // private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext) build() { Column() { TopLogo({ outFlag: $outFlag }) Flex({ justifyContent: FlexAlign.SpaceBetween }) { - Column() { - Row() { - Video({ - src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td1}/main/av_stream`:'', - currentProgressRate: this.curRate, - controller: this.controller1 - }) - .width(205 * this.ratio) - .height(168 * this.ratio) - .autoPlay(this.isAutoPlay) - .controls(this.showControls) - .margin(10 * this.ratio) - - Video({ - src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td2}/main/av_stream`:'', - currentProgressRate: this.curRate, - controller: this.controller1 - }) - .width(205 * this.ratio) - .height(168 * this.ratio) - .autoPlay(this.isAutoPlay) - .controls(this.showControls) - .margin(10 * this.ratio) - } - - Row() { - Video({ - src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td3}/main/av_stream`:'', - currentProgressRate: this.curRate, - controller: this.controller3 - }) - .width(205 * this.ratio) - .height(168 * this.ratio) - .autoPlay(this.isAutoPlay) - - .controls(this.showControls) - .margin(10 * this.ratio) - Video({ - src: this.openFlag?`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td4}/main/av_stream`:'', - // previewUri: this.previewUri, - currentProgressRate: this.curRate, - controller: this.controller4 - }) - .width(205 * this.ratio) - .height(168 * this.ratio) - .autoPlay(this.isAutoPlay) - .controls(this.showControls) - .margin(10 * this.ratio) - } - }.margin({ top: 37 * this.ratio, left: 30 * this.ratio }) + Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) { + ForEach(this.videoArr,(item,index)=>{ + Video({ + src: this.openFlag ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param[item.td]}/main/av_stream` : '', + currentProgressRate: this.curRate, + controller: item.controller + }) + .width(270 * this.ratio) + .height(230 * this.ratio) + .autoPlay(this.isAutoPlay) + .controls(this.showControls) + .margin(10 * this.ratio) + }) + }.margin({ top: 37 * this.ratio, left: 30 * this.ratio }).width(600*this.ratio).height(600*this.ratio) Column() { Image($r('app.media.shezhi')) - .width(215 * this.ratio) - .height(64 * this.ratio) - .margin({ bottom: 10 * this.ratio }) - .onClick(() => { - this.showFlag = true - }) + .width(215 * this.ratio) + .height(64 * this.ratio) + .margin({ bottom: 10 * this.ratio }) + .onClick(() => { + this.showFlag = true + }) Image($r('app.media.luxiang')) - .width(215 * this.ratio) - .height(64 * this.ratio) - .margin({ bottom: 10 * this.ratio }) + .width(215 * this.ratio) + .height(64 * this.ratio) + .margin({ bottom: 10 * this.ratio }) .onClick(async () => { - if (!this.param.videoRecord4 && !this.param.videoRecord3 && !this.param.videoRecord2 && !this.param.videoRecord1) { - prompt.showToast({ + if (!this.param.videoRecord4 && !this.param.videoRecord3 + && !this.param.videoRecord2 && !this.param.videoRecord1) { + promptAction.showToast({ message: '请选择录像通道', duration: 3000 }) return } - if (this.rocord_handle1 || this.rocord_handle2 || this.rocord_handle3 || this.rocord_handle4) { + if (this.rocordHandleObj.rocord_handle1 + || this.rocordHandleObj.rocord_handle2 + || this.rocordHandleObj.rocord_handle3 + || this.rocordHandleObj.rocord_handle4) { return } - if (this.param.videoRecord1) { - // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch1/main/av_stream`; - var mediaTest = mediaLibrary.getMediaLibrary(this.context); - let mediaType = mediaLibrary.MediaType.VIDEO; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; - const num = Math.floor(Math.random() * 10000) - const name = `movie_record${num}.mp4` - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - mediaTest.createAsset(mediaType, name, path, (error, asset) => { - this.file_asset1 = asset; // 记录 ,关闭时用到 - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name; - var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); - this.filehandle1 = fd; // 记录 ,关闭时用到 - this.rocord_handle1 = result3.dataInt; // 记录 ,关闭时用到 - } else { - console.error('baoyihu startRecordVideo File Open failed with error: ' + error); - } - }); - }); + for (let i = 1; i <= 4; i++) { + if (this.param['videoRecord'+i]) { + this.getfilehandleCode(i) + } } - if (this.param.videoRecord2) { - // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch2/main/av_stream`; - var mediaTest = mediaLibrary.getMediaLibrary(this.context); - let mediaType = mediaLibrary.MediaType.VIDEO; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; - const num = Math.floor(Math.random() * 10000) - var videoName = `movie_record${num}.mp4` - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - const that = this - mediaTest.createAsset(mediaType, videoName, path, (error, asset) => { - this.file_asset2 = asset; // 记录 ,关闭时用到 - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + videoName; - that.filehandle2 = fd // 记录 ,关闭时用到 - var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); - this.rocord_handle2 = result3.dataInt; // 记录 ,关闭时用到 - } else { - console.error(' startRecordVideo File Open failed with error: ' + error); - } - }); - }); - } - if (this.param.videoRecord3) { - // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch3/main/av_stream`; - var mediaTest = mediaLibrary.getMediaLibrary(this.context); - let mediaType = mediaLibrary.MediaType.VIDEO; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; - const num = Math.floor(Math.random() * 10000) - const name = `movie_record${num}.mp4` - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - mediaTest.createAsset(mediaType, name, path, (error, asset) => { - this.file_asset3 = asset; // 记录 ,关闭时用到 - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name; - var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); - this.filehandle3 = fd; // 记录 ,关闭时用到 - this.rocord_handle3 = result3.dataInt; // 记录 ,关闭时用到 - } else { - console.error('baoyihu startRecordVideo File Open failed with error: ' + error); - } - }); - }); - } - if (this.param.videoRecord4) { - var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch4/main/av_stream`; - var mediaTest = mediaLibrary.getMediaLibrary(this.context); - let mediaType = mediaLibrary.MediaType.VIDEO; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; - const num = Math.floor(Math.random() * 10000) - const name = `movie_record${num}.mp4` - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - mediaTest.createAsset(mediaType, name, path, (error, asset) => { - this.file_asset4 = asset; // 记录 ,关闭时用到 - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name; - var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); - this.filehandle4 = fd; // 记录 ,关闭时用到 - this.rocord_handle4 = result3.dataInt; // 记录 ,关闭时用到 - } else { - console.error('baoyihu startRecordVideo File Open failed with error: ' + error); - } - }); - }); - } - prompt.showToast({ + promptAction.showToast({ message: '录像开始', duration: 3000 }) }) Image($r('app.media.tingzhi')) - .width(215 * this.ratio) - .height(64 * this.ratio) - // .backgroundImage($r('app.media.button_nor')) - // .backgroundImageSize({ width: '100%', height: '100%' }) - .margin({ bottom: 10 * this.ratio }) - .onClick(() => { - if (this.rocord_handle4) { - var result4 = onvifclient.endRecordVideo(this.rocord_handle4); - this.rocord_handle4 = 0 - fs.closeSync(this.filehandle4) - this.file_asset1.close(this.filehandle4); - } - if (this.rocord_handle3) { - var result3 = onvifclient.endRecordVideo(this.rocord_handle3); - this.rocord_handle3 = 0 - fs.closeSync(this.filehandle3); - this.file_asset2.close(this.filehandle3); - } - if (this.rocord_handle2) { - console.log('tagtag',this.rocord_handle2,this.filehandle2) - var result = onvifclient.endRecordVideo(this.rocord_handle2); - this.rocord_handle2 = 0 - fs.closeSync(this.filehandle2); - this.file_asset2.close(this.filehandle2); + .width(215 * this.ratio) + .height(64 * this.ratio) + .margin({ bottom: 10 * this.ratio }) + .onClick(() => { + for (let i = 1; i <= 4; i++) { + if (this.rocordHandleObj['rocord_handle'+i]) { + endRecordVideo(this.rocordHandleObj['rocord_handle'+i]) + this.rocordHandleObj['rocord_handle'+i] = -1 + } } - if (this.rocord_handle1) { - var result = onvifclient.endRecordVideo(this.filehandle1); - this.rocord_handle1 = 0 - fs.closeSync(this.filehandle1); - this.file_asset2.close(this.filehandle1); - } - this.rocord_handle1 = 0 - this.rocord_handle2 = 0 - this.rocord_handle3 = 0 - this.rocord_handle4 = 0 - prompt.showToast({ + + promptAction.showToast({ message: '录像结束', duration: 3000 }) }) Image($r('app.media.zhuatu')) .width(215 * this.ratio) - .height(64 * this.ratio) + .height(64 * this.ratio) .onClick(async () => { - if (this.param.pztd != '1' && this.param.pztd != '2' && this.param.pztd != '3' && this.param.pztd != '4') { - prompt.showToast({ + const arr=['1','2','3','4'] + if(!arr.includes(this.param.pztd)){ + promptAction.showToast({ message: '请填写正确的拍照通道', duration: 3000 }) return } - // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.pztd}/main/av_stream`; - - var mediaTest = mediaLibrary.getMediaLibrary(this.context); - let mediaType = mediaLibrary.MediaType.IMAGE; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE; - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); - const randomNum = Math.floor(Math.random() * 100) - mediaTest.createAsset(mediaType, "picture_record" + randomNum + ".jpg", path, (error, asset) => { - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Pictures/picture_record" + randomNum + ".jpg" - var result3 = onvifclient.getVideoSnapshot(video_uri, file_path, fd); - fs.closeSync(fd); - asset.close(fd); - prompt.showToast({ - message: '抓图完成', - duration: 3000 - }) - } else { - console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error); - } - }); - }); - - // let mediaType = mediaLibrary.MediaType.FILE; - // let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; - // const path = await this.mediaTest.getPublicDirectory(DIR_IMAGE); - // const asset = await this.mediaTest.createAsset(mediaType, 'picture_record'+randomNum+'.jpg', path); - // console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString); + await takePhoto(this.param,this.context,0,'pz') + promptAction.showToast({ + message: '抓图完成', + duration: 3000 + }) }) - .margin({ bottom: 10 * this.ratio }) + .margin({ bottom: 10 * this.ratio }) }.margin({ right: 38 * this.ratio, top: 110 * this.ratio }) }.backgroundColor('#1A1A1A') - Column() { - Text('提示信息:') - .fontSize(18 * this.ratio) - .fontColor('#fff') - .margin({ left: 29 * this.ratio, top: 13 * this.ratio }) - .align(Alignment.Start) - .width('100%') - }.width('100%').height(70 * this.ratio).backgroundColor('#333230').position({ x: 0, y: 470 * this.ratio }) + // Column() { + // Text('提示信息:') + // .fontSize(18 * this.ratio) + // .fontColor('#fff') + // .margin({ left: 29 * this.ratio, top: 13 * this.ratio }) + // .align(Alignment.Start) + // .width('100%') + // }.width('100%').height(70 * this.ratio).backgroundColor('#333230').position({ x: 0, y: 470 * this.ratio }) if (this.showFlag) { Column() { @@ -383,7 +217,7 @@ struct Index { Row() { Image($r('app.media.fh')).width(117 * this.ratio).height(50 * this.ratio).onClick(() => { // this.oldParam = JSON.parse(JSON.stringify(this.param)) - this.param=JSON.parse(JSON.stringify(this.oldParam)) + this.param = JSON.parse(JSON.stringify(this.oldParam)) this.showFlag = false }) Image($r('app.media.bc')) @@ -401,23 +235,23 @@ struct Index { Column() { Row() { Text('视频路数').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 13 * this.ratio }) - TextInput({ text: this.videoNum, controller: this.inputController }) + TextInput({ text: this.param.videoNum, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(34 * this.ratio) .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .margin({ left: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) .onChange((value) => { this.param.spls = value }) Column() { Image($r('app.media.shang')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => { - this.videoNum = (parseInt(this.videoNum) + 1).toString() + this.param.videoNum = (parseInt(this.param.videoNum) + 1).toString() }) Image($r('app.media.xia')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => { - this.videoNum = (parseInt(this.videoNum) - 1).toString() + this.param.videoNum = (parseInt(this.param.videoNum) - 1).toString() }) }.margin({ left: 5 * this.ratio, right: 10 * this.ratio }) @@ -434,9 +268,9 @@ struct Index { .type(InputType.Normal) .borderRadius(0) .width(34 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) .onChange((value) => { this.param.rlls = value @@ -445,10 +279,10 @@ struct Index { TextInput({ text: this.param.pztd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .width(34 * this.ratio) .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) .onChange((value: string) => { this.param.pztd = value @@ -456,34 +290,29 @@ struct Index { Text('设备类型').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: '海康', controller: this.inputController }) .borderRadius(0) - .padding({ bottom:0,top:0 }) + .padding({ bottom: 0, top: 0 }) .width(67 * this.ratio) .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) - // Select([{ value: '一路',}, - // { value: '二路', }, - // { value: '三路',}, - // { value: '四路' }]).width(67 * this.ratio).borderRadius(0) .height(26 * this.ratio).selected(2).margin({ left: 10 * this.ratio,right:15*this.ratio }) - Text('信号大小').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.spls, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .width(34 * this.ratio) .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) Text('k').fontColor('#333333').fontSize(16 * this.ratio) Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.ljlx, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .width(34 * this.ratio) .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) .margin({ left: 10 * this.ratio, right: 5 * this.ratio }) }.width('100%').align(Alignment.Start).backgroundColor('#E5E3DF') @@ -492,7 +321,6 @@ struct Index { Row() { Row() { }.width(70 * this.ratio) - Text('IP地址') .width(158 * this.ratio) .fontSize(16 * this.ratio) @@ -525,274 +353,74 @@ struct Index { .textAlign(TextAlign.Center) } - Row() { - Text('第一路') - .width(70 * this.ratio) - .fontColor('#333333') - .fontSize(16 * this.ratio) - .textAlign(TextAlign.Center) - TextInput({ text: this.param.ip, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(158 * this.ratio) - .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .onChange((value: string) => { - this.param.ip = value - }) - TextInput({ text: this.param.td1, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(96 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.td1 = value - }) - TextInput({ text: this.param.userName, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .margin({ right: 10 * this.ratio }) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.userName = value - }) - TextInput({ text: this.param.pwd, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) - .margin({ right: 10 * this.ratio }) - .padding({ top:0,bottom:0 }) - .onChange((value: string) => { - this.param.pwd = value - }) - TextInput({ text: this.param.port, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(60 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.port = value - }) - }.margin({ top: 10 * this.ratio }) + ForEach(this.lsArr,(item,index)=>{ + Row() { + Text(item.key) + .width(70 * this.ratio) + .fontColor('#333333') + .fontSize(16 * this.ratio) + .textAlign(TextAlign.Center) + TextInput({ text: this.param.ip, controller: this.inputController }) + .type(InputType.Normal) + .borderRadius(2) + .width(158 * this.ratio) + .height(26 * this.ratio) + .fontSize(this.inputFontSize * this.ratio) + .padding({ top: 0, bottom: 0 }) + .margin({ right: 10 * this.ratio }) + .onChange((value: string) => { + this.param.ip = value + }) + TextInput({ text: this.param['td'+index+1], controller: this.inputController }) + .type(InputType.Normal) + .borderRadius(2) + .width(96 * this.ratio) + .height(26 * this.ratio) + .padding({ top: 0, bottom: 0 }) + .margin({ right: 10 * this.ratio }) + .fontSize(this.inputFontSize * this.ratio) + .onChange((value: string) => { + this.param.td1 = value + }) + TextInput({ text: this.param.userName, controller: this.inputController }) + .type(InputType.Normal) + .borderRadius(2) + .width(120 * this.ratio) + .height(26 * this.ratio) + .margin({ right: 10 * this.ratio }) + .padding({ top: 0, bottom: 0 }) + .fontSize(this.inputFontSize * this.ratio) + .onChange((value: string) => { + this.param.userName = value + }) + TextInput({ text: this.param.pwd, controller: this.inputController }) + .type(InputType.Normal) + .borderRadius(2) + .width(120 * this.ratio) + .height(26 * this.ratio) + .fontSize(this.inputFontSize * this.ratio) + .margin({ right: 10 * this.ratio }) + .padding({ top: 0, bottom: 0 }) + .onChange((value: string) => { + this.param.pwd = value + }) + TextInput({ text: this.param.port, controller: this.inputController }) + .type(InputType.Normal) + .borderRadius(2) + .width(60 * this.ratio) + .height(26 * this.ratio) + .padding({ top: 0, bottom: 0 }) + .margin({ right: 10 * this.ratio }) + .fontSize(this.inputFontSize * this.ratio) + .onChange((value: string) => { + this.param.port = value + }) + }.margin({ top: 10 * this.ratio }) + }) - Row() { - Text('第二路') - .width(70 * this.ratio) - .fontColor('#333333') - .fontSize(16 * this.ratio) - .textAlign(TextAlign.Center) - TextInput({ text: this.param.ip, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .padding({ top:0,bottom:0 }) - .width(158 * this.ratio) - .height(26 * this.ratio) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.ip = value - }) - TextInput({ text: this.param.td2, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(96 * this.ratio) - .height(26 * this.ratio) - .margin({ right: 10 * this.ratio }) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.td2 = value - }) - TextInput({ text: this.param.userName, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.userName = value - }) - TextInput({ text: this.param.pwd, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .padding({ top:0,bottom:0 }) - .width(120 * this.ratio) - .height(26 * this.ratio) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.pwd = value - }) - TextInput({ text: this.param.port, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(60 * this.ratio) - .padding({ top:0,bottom:0 }) - .height(26 * this.ratio) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.port = value - }) - }.margin({ top: 10 * this.ratio }) - - Row() { - Text('第三路') - .width(70 * this.ratio) - .fontColor('#333333') - .fontSize(16 * this.ratio) - .textAlign(TextAlign.Center) - TextInput({ text: this.param.ip, controller: this.inputController }) - .type(InputType.Normal) - .fontSize(this.inputFontSize*this.ratio) - .borderRadius(2) - .width(158 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .onChange((value: string) => { - this.param.ip = value - }) - TextInput({ text: this.param.td3, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(96 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.td3 = value - }) - TextInput({ text: this.param.userName, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.userName = value - }) - TextInput({ text: this.param.pwd, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.pwd = value - }) - TextInput({ text: this.param.port, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(60 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) - .margin({ right: 10 * this.ratio }) - .onChange((value: string) => { - this.param.port = value - }) - }.margin({ top: 10 * this.ratio }) - - Row() { - Text('第四路') - .width(70 * this.ratio) - .fontColor('#333333') - .fontSize(16 * this.ratio) - .textAlign(TextAlign.Center) - TextInput({ text: this.param.ip, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(158 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) - .margin({ right: 10 * this.ratio }) - .onChange((value: string) => { - this.param.ip = value - }) - TextInput({ text: this.param.td4, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(96 * this.ratio) - .height(26 * this.ratio) - .fontSize(this.inputFontSize*this.ratio) - .margin({ right: 10 * this.ratio }) - .padding({ top:0,bottom:0 }) - .onChange((value: string) => { - this.param.td4 = value - }) - TextInput({ text: this.param.userName, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.userName = value - }) - TextInput({ text: this.param.pwd, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(120 * this.ratio) - .height(26 * this.ratio) - .margin({ right: 10 * this.ratio }) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.param.pwd = value - }) - TextInput({ text: this.param.port, controller: this.inputController }) - .type(InputType.Normal) - .borderRadius(2) - .width(60 * this.ratio) - .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .margin({ right: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .onChange((value: string) => { - this.oldParam.port = value - }) - }.margin({ top: 10 * this.ratio }) }.width(672 * this.ratio).height(174 * this.ratio).backgroundColor('#EDEBE8') Column() { - Row() { - // Text('录像方式').fontSize(16*this.ratio).fontColor('#333333') - // TextInput({ text: this.param.spls, controller: this.inputController }) - // .type(InputType.Number) - // .borderRadius(0) - // .width(160 * this.ratio) - // .height(26 * this.ratio) - // .margin({ left: 10 * this.ratio }) - // Select([{ value: '一路',}, - // { value: '二路', }, - // { value: '三路',}, - // { value: '四路' }]).width(160 * this.ratio).borderRadius(0) .height(26 * this.ratio).selected(2).margin({ left: 10 * this.ratio,right:15*this.ratio }) - } - Row() { Text('录像范围').fontSize(16 * this.ratio).fontColor('#333333').margin({ top: 10 * this.ratio }) Row() { @@ -905,8 +533,8 @@ struct Index { .borderRadius(0) .width(79 * this.ratio) .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) + .padding({ top: 0, bottom: 0 }) + .fontSize(this.inputFontSize * this.ratio) .margin({ left: 10 * this.ratio }) Text('叠加内容').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.text1, controller: this.inputController }) @@ -914,27 +542,27 @@ struct Index { .borderRadius(0) .width(79 * this.ratio) .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .margin({ left: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) Text('+').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 5 * this.ratio }) TextInput({ text: this.param.text2, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(79 * this.ratio) .height(26 * this.ratio) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .margin({ left: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) Text('+').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 5 * this.ratio }) TextInput({ text: this.param.text3, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(79 * this.ratio) - .padding({ top:0,bottom:0 }) + .padding({ top: 0, bottom: 0 }) .height(26 * this.ratio) .margin({ left: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) + .fontSize(this.inputFontSize * this.ratio) Text('分隔符').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.dolt, controller: this.inputController }) .type(InputType.Normal) @@ -942,8 +570,8 @@ struct Index { .width(67 * this.ratio) .height(26 * this.ratio) .margin({ left: 10 * this.ratio }) - .padding({ top:0,bottom:0 }) - .fontSize(this.inputFontSize*this.ratio) + .padding({ top: 0, bottom: 0 }) + .fontSize(this.inputFontSize * this.ratio) Text('文字大小').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.fontSize, controller: this.inputController }) .type(InputType.Normal) @@ -951,52 +579,17 @@ struct Index { .width(34 * this.ratio) .height(26 * this.ratio) .margin({ left: 10 * this.ratio }) - .fontSize(this.inputFontSize*this.ratio) - .padding({ top:0,bottom:0 }) + .fontSize(this.inputFontSize * this.ratio) + .padding({ top: 0, bottom: 0 }) }.width('100%').align(Alignment.Start).backgroundColor('#E5E3DF') - // Flex(){ - // Text('本考车对应视频合成信息处理系统IP、本地响应端口') - // .fontSize(16*this.ratio).fontColor('#333333').width(500*this.ratio).margin({left:5*this.ratio}) - // TextInput({ text: this.param.spls, controller: this.inputController }) - // .type(InputType.Number) - // .borderRadius(0) - // .width(200 * this.ratio) - // .height(26 * this.ratio) - // .margin({ left: 10 * this.ratio }) - // TextInput({ text: this.param.spls, controller: this.inputController }) - // .type(InputType.Number) - // .borderRadius(0) - // .width(58 * this.ratio) - // .height(26 * this.ratio) - // .margin({ left: 10 * this.ratio }) - // Text('填错或不填将可能导致录像丢失') - // .fontSize(16*this.ratio).fontColor('#FF7F66').width(400*this.ratio).margin({left:20*this.ratio}) - // }.align(Alignment.Start).margin({top:10*this.ratio}) - // Flex(){ - // Text('本考车对应视频合成服务器IP、端口') - // .fontSize(16*this.ratio).fontColor('#333333').width(500*this.ratio).margin({left:5*this.ratio}) - // TextInput({ text: this.param.spls, controller: this.inputController }) - // .type(InputType.Number) - // .borderRadius(0) - // .width(200 * this.ratio) - // .height(26 * this.ratio) - // .margin({ left: 10 * this.ratio }) - // TextInput({ text: this.param.spls, controller: this.inputController }) - // .type(InputType.Number) - // .borderRadius(0) - // .width(58 * this.ratio) - // .height(26 * this.ratio) - // .margin({ left: 10 * this.ratio }) - // Text('填错将不能开始考试') - // .fontSize(16*this.ratio).fontColor('#FF7F66').width(400*this.ratio).margin({left:20*this.ratio}) - // }.align(Alignment.Start).margin({top:10*this.ratio}) + }.width(946 * this.ratio).height(336 * this.ratio).backgroundColor('#E5E3DF').margin({ top: 13 * this.ratio }) } .width('100%') .height(395 * this.ratio) .backgroundColor('#CCC4B8') - .position({ x: 0, y: 146 * this.ratio }) + .position({ x: 0, y: 460 * this.ratio }) .border({ radius: { topLeft: 24 * this.ratio, topRight: 24 * this.ratio } }) } @@ -1004,49 +597,17 @@ struct Index { } aboutToAppear() { - this.openFlag=true + this.openFlag = true const fileUtil = new FileUtil(this.context) this.fileUtil = fileUtil - //获取参数配置 - // this.vocObj = new voiceService(async (status, val) => { - // if (status == 'idle') { - // - // } - // }); this.getVideoConfig() - // return - // // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - // - // var - // loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' } - // - // // var result = onvifclient.getAllOSD(loginInfo); - // // var create_str = "{\"VideoSourceToken\": \"VideoSourceToken\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\": 0.15454499125480652,\"Position_Y\": -0.477780294418335,\"TextType\": \"Plain\",\"FontSize\": 32,\"PlainText\": \"Camera 99\"}" - // var create_str = { - // "ConfigurationToken": "VideoSourceToken", - // "Type": "Text", - // "PositionType": "Custom", - // "Position_X": 0.15454499125480652, - // "Position_Y": -0.477780294418335, - // "TextType": "Plain", - // "FontSize": 32, - // "PlainText": "Camera 99" - // } - // var result = onvifclient.createOSD(loginInfo, JSON.stringify(create_str)); - // console.info(`baoyihu createOSD end result:` + result.result + ` dataString:` + result.dataString); - - - // console.info( `baoyihu getAllOSD end result:`+result.result+ ` dataString:`+result.dataString ); - // var set_str = {"ConfigurationToken": "VideoSourceToken","OSDToken": "OsdToken_100","Type": "Text","PositionType": "Custom","Position_X": 0.45454499125480652,"Position_Y": -0.077780294418335,"TextType": "Plain","FontSize": 32,"PlainText": "baoyihu shige dahaoren"} - // console.info('Index onPageShow'); } - + async getfilehandleCode(td){ + const record_handle = await startRecordVideo(this.param,td,this.context,'lp') + this.rocordHandleObj['rocord_handle1'+td]=record_handle + } outClick() { - this.openFlag=false - } - - async init() { - + this.openFlag = false } async onPageShow() { @@ -1054,92 +615,16 @@ struct Index { } async getVideoConfig() { - const data = await this.fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/config3.txt'); + const data = await this.fileUtil.readFile(configAddress.comoonfileWriteAddress+'/config/config3.txt'); this.oldParam = JSON.parse(data) this.param = JSON.parse(data) } async writeConfig() { this.oldParam = JSON.parse(JSON.stringify(this.param)) - const param = { - videoNum: this.videoNum, //视频路数 - faceFlag: this.param.faceFlag, //启用人脸比对 - pztd: this.param.pztd, //拍照通道 - ljlx: this.param.ljlx, - ip: this.param.ip, - port: this.param.port, - userName: this.param.userName, - pwd: this.param.pwd, - td1: this.param.td1, - td2: this.param.td2, - td3: this.param.td3, - td4: this.param.td4, - wz: this.param.wz, - text3: this.param.text3, - text2: this.param.text2, - text1: this.param.text1, - dolt: this.param.dolt, - shuiying: this.param.shuiying, - fontSize: this.param.fontSize, - rlls: this.param.rlls, - videoRecord1:this.param.videoRecord1, - videoRecord2:this.param.videoRecord2, - videoRecord3:this.param.videoRecord3, - videoRecord4:this.param.videoRecord4 - } const folderPath = await this.fileUtil.initFolder(`/config`); - this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(param), 'overWrite') + this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite') this.showFlag = false - // if(this.param.shuiying) { - // //查询水印 - // var loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' } - // var result = onvifclient.getAllOSD(loginInfo); - // console.info( `baoyihu getAllOSD end result:`+result.result+ ` dataString:`+result.dataString ); - // let text='' - // if(this.param.dolt!=''){ - // if(this.param.text1){ - // text+=this.param.text1 - // } - // if(this.param.text2){ - // text+=this.param.dolt+this.param.text2 - // } - // if(this.param.text3){ - // text+=this.param.dolt+this.param.text3 - // } - // } - // else{ - // if(this.param.text1){ - // text+=this.param.text1 - // } - // if(this.param.text2){ - // text+=','+this.param.text2 - // } - // if(this.param.text3){ - // text+=','+this.param.text3 - // } - // } - // let x='0'; - // let y='0' - // if(this.param.wz){ - // x=this.param.wz.split(',')[0] - // y=this.param.wz.split(',')[0] - // } - // if(result.result){ - // //存在 - // var set_str = `{\"ConfigurationToken\": \"VideoSourceToken\",\"OSDToken\": \"OsdToken_100\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\":${x},\"Position_Y\": ${y},\"TextType\": \"Plain\",\"FontSize\": ${this.param.fontSize},\"PlainText\": \"${text}\"}` - // var result = onvifclient.setOSD(loginInfo,set_str); - // }else{ - // var create_str = `{\"ConfigurationToken\": \"VideoSourceToken\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\": 0.15454499125480652,\"Position_Y\": -0.477780294418335,\"TextType\": \"Plain\",\"FontSize\": 32,\"PlainText\": \"Camera 99\"}` - // var result = onvifclient.createOSD(loginInfo,create_str); - // console.info( `baoyihu createOSD end result:`+result.result+ ` dataString:`+result.dataString ); - // } - // }else{ - // // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - // - // var loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' } - // var result1 = onvifclient.deleteOSD(loginInfo,"OsdToken_102"); - // console.info( `baoyihu deleteOSD end result:`+result1.result+ ` dataString:`+result1.dataString ); - // } - // const isEdit = this.fileUtilObj.editFile(`${folderPath}/videoConfig.txt`,param.toString()) + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets b/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets index 986db4a..8baddb2 100644 --- a/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets +++ b/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets @@ -1,32 +1,19 @@ //@ts-ignore -import camera from '@ohos.multimedia.camera'; -import image from '@ohos.multimedia.image' + import util from '@ohos.util'; -import { writeFile } from '../../common/service/fileService' -import TopLogo from '../compontents/topLogo' -import { cameraService } from '../../common/service/cameraService' + import { voiceService } from '../../common/service/voiceService' import { faceCompare } from '../../api/userInfo' -import prompt from '@ohos.prompt' -import grantPermission from '../../common/utils/PermissionUtils'; -import CameraModel from '../../common/service/CameraModel'; import FileUtil from '../../common/utils/File' import { VideoConfig } from '../interfaces' import common from '@ohos.app.ability.common'; -import fs from '@ohos.file.fs' -import onvifclient from '@ohos.onvifclient'; -import buffer from '@ohos.buffer'; -import mediaLibrary from '@ohos.multimedia.mediaLibrary' -// import MediaModel from '../../common/utils/MediaModel'; -let previewWidth; -let previewHeight; - -const PERMISSIONS: Array = [ - 'ohos.permission.CAMERA'] +import { string2Bytes } from '../../common/utils/tools' +import { takePhoto } from '../../common/service/videoService' +import configAddress from '../../common/utils/FileConfig' @Component -export default struct FaceCompare { +struct FaceCompare { constructor() { super() } @@ -35,21 +22,15 @@ export default struct FaceCompare { @Prop sfzh: string; @Prop lsh: string; @Prop firstImage: string; - @Link showFaceCompare: boolean; @Link faceCompareSucess: number; @Link getqkFlag: boolean; @Link faceCatchImg: string; @State imageThumbnail: string = ''; - private timer = null; //人脸比对执行任务定时器 - private stopClose = false; // 阻止用户关闭此组件 private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 private vocObj = null; - @State callBackFlag:boolean=false; - @State @Watch('changeFaceCompareSuccess') showFaceCompare2: Boolean = false; - - private surfaceId: string = ''; + @State callBackFlag: boolean = false; + @State @Watch('clearIntervalFn') showFaceCompare: Boolean = false; @State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream' - private fileAsset: mediaLibrary.FileAsset = undefined; @State previewUri: Resource = $r('app.media.2_nor') @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State showControls: boolean = false @@ -58,10 +39,9 @@ export default struct FaceCompare { @State signNum: number = 0; private fileUtil: FileUtil private interval: any - private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext) - private fd: number = -1; @State param: VideoConfig = { spls: '', + videoNum: '1', faceFlag: false, pztd: '1', ljlx: '', @@ -93,7 +73,7 @@ export default struct FaceCompare { Row() { Row() { Video({ - src: `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`, + src: this.showFaceCompare ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream` : '', previewUri: this.previewUri, currentProgressRate: PlaybackSpeed.Speed_Forward_1_00_X, controller: this.controller, @@ -146,9 +126,7 @@ export default struct FaceCompare { .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(async () => { this.times = 1; - // this.takePhoto('face_check.mp3'); - // this.readyToTakePhoto(this.surfaceId); - // await this.cameraObj.releaseSource() + }) } .width('88.9%') @@ -174,29 +152,11 @@ export default struct FaceCompare { .backgroundImage($r('app.media.close')) .backgroundImageSize({ width: '100%', height: '100%' }) .onClick(() => { - // prompt.showToast({ - // message: '人脸比对程序正在执行,请等待程序执行完毕。', - // duration: 3000 - // }); this.controller.stop() - this.vocObj&&this.vocObj.releasePlayer() - this.showFaceCompare = false - this.showFaceCompare2 = false + this.vocObj && this.vocObj.releasePlayer() + this.showFaceCompare = !this.showFaceCompare this.faceCompareSucess = -1 - return - console.log('jiangsong close the faceCompare componet'); - if (!this.stopClose) { - this.showFaceCompare = false - this.showFaceCompare2 = false - - } else { - prompt.showToast({ - message: '人脸比对程序正在执行,请等待程序执行完毕。', - duration: 3000 - }); - this.showFaceCompare = false - } }) } .width('100%') @@ -206,351 +166,162 @@ export default struct FaceCompare { } onPageShow() { - // this.cameraModel.initCamera(this.surfaceId); - - } - changeFaceCompareSuccess(){ - this.callBackFlag=false - clearInterval(this.interval) - this.vocObj&&this.vocObj.releasePlayer() } async aboutToAppear() { - this.callBackFlag=false - clearInterval(this.interval) - // this.mediaModel = MediaModel.getMediaInstance(); const fileUtil = new FileUtil(this.context) this.fileUtil = fileUtil this.getVideoConfig() - - - // this.cameraModel.setTakePictureHandleCallback(this.takePictureHandle.bind(this)); } - getqkFn(){ - let tmpList = []; - // const str =globalThis.signNum - // for (let i = 0;i < str.length; i++) { - // tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) - // } - // const arr = [globalThis.signNum||0, globalThis.statue||1] - // let tmpList = []; - tmpList.push(this.string2Bytes(globalThis.signNum, 1 * 8)[0]) - const param= {id: 41,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId} + clearIntervalFn() { + this.callBackFlag = false + clearInterval(this.interval) + this.vocObj && this.vocObj.releasePlayer() + } + + getqkFn() { + let tmpList = []; + tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0]) + const param = { + id: 41, + list: tmpList, + carNo: globalThis.carInfo.carNo, + placeId: globalThis.carInfo.examinationRoomId + } globalThis.udpClient2.sendMsg(param, this.context) } async faceComparFn() { - var loginInfo1 = { - host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } - // var file_dir = "/data/service/el1/public/netmanager/ethernet/"; - // var result3 = onvifclient.getVideoSnapshot(loginInfo1, video_uri, file_dir); - // console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString); - var mediaTest = mediaLibrary.getMediaLibrary(this.context); - let mediaType = mediaLibrary.MediaType.IMAGE; - let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE; - const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); + const result = await takePhoto(this.param, this.context, 1,'jt') + faceCompare({ + sfzh: this.sfzh, + firstImage: this.firstImage.substr(22), + secondImage: result, + type: 2, + verifyType: 1 + }).then(res => { + if (res) { + this.controller.stop() + this.showFaceCompare = !this.showFaceCompare + this.faceCompareSucess = 1; + // this.faceCatchImg = result + this.vocObj.playAudio({ + type: 1, + name: 'yzcg.wav' + }) + } else { + this.times++; + //3s后开始语音提示 + this.vocObj.playAudio({ + type: 1, + name: 'face_fail.mp3' + }) - const fileName = 'FaceCompar' + Math.floor(Math.random() * 1000) + '.jpg' - mediaTest.createAsset(mediaType, fileName, path, (error, asset) => { - asset.open('rw', (error, fd) => { - if (fd > 0) { - var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Pictures/" + fileName - var result3 = onvifclient.getVideoSnapshot(`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`, file_path, fd); - fs.closeSync(fd); - asset.close(fd); - // let filePath = pathDir + "/test.txt"; - fs.lstat(file_path).then((stat) => { - console.info("get link status succeed, the size of file is" + stat.size); - let file = fs.openSync(file_path, fs.OpenMode.READ_WRITE); - const size = Number(stat.size) + 100 - let buf = new ArrayBuffer(size); - let num = fs.readSync(file.fd, buf); - var that = new util.Base64(); - var array = new Uint8Array(buf); - var result = that.encodeToStringSync(array); //base64圖片 - // - mediaTest.deleteAsset(file_path).then(() => { - console.log('delSuccess') - }).catch(() => { - console.log('delError') - }) - this.fileUtil.deleteF(file_path, 3) - if(this.firstImage){ - this.faceCatchImg = result - }else{ - this.faceCatchImg = '' - - } - - faceCompare({ - sfzh: this.sfzh, - firstImage:this.firstImage.substr(22), - // sfzh: '321281198605076819', - // firstImage: this.firstImage, - secondImage: result, - type: 2, - verifyType: 1 - }).then(res => { - if (res) { - this.controller.stop() - console.log('jiangsong face compare success' + JSON.stringify(res)) - this.showFaceCompare = false - this.showFaceCompare2 = false - this.faceCompareSucess = 1; - // this.faceCatchImg = result - this.vocObj.playAudio({ - type: 1, - name: 'yzcg.wav' - }) - } else { - console.log('jiangsong face compare faild') - // this.showFaceCompare = false - // this.faceCompareSucess = false; - this.times++; - //3s后开始语音提示 - this.vocObj.playAudio({ - type: 1, - name: 'face_fail.mp3' - }) - // this.timer = setTimeout(() => { - // this.takePhoto('face_fail.mp3'); - // }, 3000) - } - }) - // console.log(result) - //result base64 - // this.fileUtil.deleteF(file_path,3) - }).catch((err) => { - console.info("get link status failed with error message: " + err.message + ", error code: " + err.code); - }); - } else { - console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error); - } - }); - }); - - } - async heartMsg(context) { - let tmpList=[] - const str =this.lsh - for (let i = 0;i < str.length; i++) { - tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0]) - } - const param = { id: 46, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId,callback:()=>{ - console.log('46send') - this.callBackFlag=true - }} - this.interval=setInterval(()=>{ - console.log('klklklk',this.callBackFlag) - if(this.callBackFlag){ - console.log('klklklk') - const param2 = { id: 47, list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId } - globalThis.udpClient2&&globalThis.udpClient2.sendMsg(param2,this.context) } - },1000) - // const param = { id: 31, list: tmpList, carNo: 489, placeId: 62 } - globalThis.udpClient2&&globalThis.udpClient2.sendMsg(param, this.context) + }) - // return {id: 31,list:tmpList,carNo:489,placeId:62} } - async getVideoConfig() { - const data = await this.fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/config3.txt'); - console.log('data,data',data) - if(!data){ - this.vocObj = new voiceService(async (status, val, next) => { - if (status == 'idle') { - if (val == 'face_check.mp3' || val == 'face_fail.mp3') { - console.log('this.time',this.times) - if (this.times >=3) { - this.vocObj&&this.vocObj.playAudio({ - type: 1, - name: 'face_checking.wav' - }) - // this.showFaceCompare = false - globalThis.statue=3 - this.faceCompareSucess = -1; - this.heartMsg(this.context) - }else{ - setTimeout(()=>{ - this.faceComparFn() - },2000) + + async heartMsg(context) { + let tmpList = [] + const str = this.lsh + for (let i = 0;i < str.length; i++) { + tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) + } + const param = { + id: 46, + list: tmpList, + carNo: globalThis.carInfo.carNo, + placeId: globalThis.carInfo.examinationRoomId, + sendCallback: () => { + this.callBackFlag = true + } + } + this.interval = setInterval(() => { + if (this.callBackFlag) { + const param2 = { + id: 47, + list: tmpList, + carNo: globalThis.carInfo.carNo, + placeId: globalThis.carInfo.examinationRoomId, + callback: (val) => { + if (val.id == '48') { + if (val.body[13] == '1') { + this.showFaceCompare = !this.showFaceCompare + this.vocObj && this.vocObj.releasePlayer() + this.faceCompareSucess = 1 + clearInterval(this.interval) + } else if (val.body[13] == '0' && this.callBackFlag) { + globalThis.statue = 2 + this.vocObj && this.vocObj.playAudio({ + type: 1, + name: 'face_chekc_fail.wav' + }) + } } - } else if (val == 'yzcg.wav') { - // this.sfbdinterfaceFn() - this.showFaceCompare = false - this.showFaceCompare2 = false - this.vocObj&&this.vocObj.releasePlayer() - globalThis.statue=4 - this.faceCompareSucess = 1; - }else if(val=='face_checking.wav'){ - // globalThis.statue=3 - this.faceCompareSucess = -1; - this.callBackFlag=false - this.vocObj&&this.vocObj.releasePlayer() - }else if(val=='face_chekc_fail.wav'){ - this.vocObj&&this.vocObj.releasePlayer() - this.faceCompareSucess=-1 - this.showFaceCompare = false - this.showFaceCompare2 = false - this.callBackFlag=false } } - }); - return - } - this.param = JSON.parse(data) - // this.param.userName = JSON.parse(data).userName - // this.param.ip = JSON.parse(data).ip - // this.param.pwd = JSON.parse(data).pwd - // this.param.port = JSON.parse(data).port - // this.param.rlls = JSON.parse(data).rlls - console.log('this.parm', this.param.userName, this.param.pwd, this.param.ip, this.param.port, this.param.rlls) - this.controller.start() - // this.video_url = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.rlls}/main/av_stream`; + globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context) + } + }, 1000) + globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context) + + } + + async getVideoConfig() { this.vocObj = new voiceService(async (status, val, next) => { if (status == 'idle') { if (val == 'face_check.mp3' || val == 'face_fail.mp3') { if (this.times >= 3) { - // this.showFaceCompare = false - globalThis.statue=3 + globalThis.statue = 3 this.faceCompareSucess = -1; - this.vocObj&&this.vocObj.playAudio({ + this.vocObj && this.vocObj.playAudio({ type: 1, name: 'face_checking.wav' }) this.heartMsg(this.context) - }else{ - setTimeout(()=>{ + } else { + setTimeout(() => { this.faceComparFn() - },2000) + }, 2000) } } else if (val == 'yzcg.wav') { - // this.sfbdinterfaceFn() - this.showFaceCompare = false - this.showFaceCompare2 = false - globalThis.statue=4 + this.showFaceCompare = !this.showFaceCompare + globalThis.statue = 4 this.faceCompareSucess = 1; - this.vocObj&&this.vocObj.releasePlayer() + this.vocObj && this.vocObj.releasePlayer() - } else if(val=='face_chekc_fail.wav'){ - this.vocObj&&this.vocObj.releasePlayer() - this.faceCompareSucess=-1 - this.showFaceCompare = false - this.showFaceCompare2 = false - this.callBackFlag=false + } else if (val == 'face_chekc_fail.wav') { + this.vocObj && this.vocObj.releasePlayer() + this.faceCompareSucess = -1 + this.showFaceCompare = !this.showFaceCompare } - // else if(val=='face_checking.wav'){ - // // console.log('kkkk') - // this.vocObj&&this.vocObj.releasePlayer() - // // globalThis.statue=3 - // // this.faceCompareSucess = -1; - // } } }); + + const data = await this.fileUtil.readFile(configAddress.comoonfileWriteAddress + '/config/config3.txt'); setTimeout(() => { - this.vocObj&&this.vocObj.playAudio({ + this.vocObj && this.vocObj.playAudio({ type: 1, name: 'face_check.mp3' }) }, 1000) - this.setUdp() - // this.cameraModel.initCamera(this.surfaceId); - - } - setUdp(){ - const that=this - globalThis.udpClient2&&globalThis.udpClient2.onMessage((val)=>{ - console.log('qkqkqk',val.id,val.body) - if(val.id=='32'){ - globalThis.signNum=val.body[1] - if(val.body[0]=='7'){ - this.getqkFn() - this.signNum=val.body[1] - } - }else if(val.id=='48'){ - if(val.body[13]=='1'){ - that.showFaceCompare = false - that.showFaceCompare2 = false - that.vocObj&&that.vocObj.releasePlayer() - that.faceCompareSucess=1 - this.callBackFlag=false - clearInterval(that.interval) - }else if(val.body[13]=='0'&&this.callBackFlag){ - this.callBackFlag=false - globalThis.statue=2 - console.log('callBackFlag',this.callBackFlag) - that.vocObj&&that.vocObj.playAudio({ - type: 1, - name: 'face_chekc_fail.wav' - }) - } - }else if(val.id=='42'){ - console.log('qkqkqk') - this.getqkFlag=!this.getqkFlag - } - }) - } - fillZero(str, len) { - str = str + ''; - if (str.length > len || !len) { - return str - } - - let num = len - str.length; - let zeroStr = ''; - for (var i = 0; i < num; i++) { - zeroStr = zeroStr + '0' - } - - return zeroStr + str; + this.param = JSON.parse(data) + this.param.userName = JSON.parse(data).userName + this.param.ip = JSON.parse(data).ip + this.param.pwd = JSON.parse(data).pwd + this.param.port = JSON.parse(data).port + this.param.rlls = JSON.parse(data).rlls + this.controller.start() } - // takePictureHandle = (thumbnail: string) => { - // this.imageThumbnail = thumbnail; - // }; - string2Bytes(number, len) { - // console.log('string2Bytes == ', number) - let str = (+number).toString(2); - if(str.length > len) { - console.log('数据长度不对~~'); - return - } - var byteString = this.fillZero(str, len); - var arrBytes = new Array(); - for (var i = byteString.length; i > 0;) { - let j = i - 8; - if (j < 0) { - j = 0 - } - var s = byteString.slice(j, i); - var v = parseInt(s, 2); - arrBytes.push(v); - i = i - 8 - - } - return arrBytes; - } async aboutToDisappear() { - // this.mediaModel = MediaModel.getMediaInstance(); } - - takePhoto(name) { - this.stopClose = true; - if (this.times > 3) { - this.stopClose = false; - return; - } - this.times++; - - // this.vocObj.playAudio({ - // type: 1, - // name: name - // }) - } } +export default FaceCompare \ No newline at end of file diff --git a/entry/src/main/ets/pages/judgeSDK/api/index.ts b/entry/src/main/ets/pages/judgeSDK/api/index.ts index 27cddcc..d6e4911 100644 --- a/entry/src/main/ets/pages/judgeSDK/api/index.ts +++ b/entry/src/main/ets/pages/judgeSDK/api/index.ts @@ -1,5 +1,6 @@ import libJudgeSdk from 'libJudgeSdk.so' // import libJudgeSdk from '@ohos.judgesdk' + /** * 苏仁君 * @date 2023/04/10 diff --git a/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts b/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts index a99d7f9..ea57d6e 100644 --- a/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts +++ b/entry/src/main/ets/pages/judgeSDK/dataTest/index.ts @@ -530,6 +530,7 @@ export const testRealExam = { }, "extend": {} } + export const testAllitems = [ {name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'1'}, {name:'倒车入库',abbreviation:'倒车入库',projectCode:'0',projectCodeCenter:'20100',type:'2'}, diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ts b/entry/src/main/ets/pages/judgeSDK/judge.ts index f65cbea..bb53a10 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ts +++ b/entry/src/main/ets/pages/judgeSDK/judge.ts @@ -109,6 +109,7 @@ export default class Judge{ if(isTrajectoryOpen){ beginExamInfo = JSON.parse(strArr[1]) }else{ + //获取开始考试数据 beginExamInfo = await getJudgeBeginData() } await fileLog.setExamJudgeData(beginExamInfo) @@ -153,6 +154,7 @@ export default class Judge{ const udpIndex = globalThis.udpIndex; if(udpIndex % 5 === 0){ const judgeUdp = globalThis.judgeUdp + //平台实时轨迹心跳 const bytes= await this.getMessageHeartbeat(); judgeUdp.send(bytes) } @@ -295,14 +297,14 @@ export default class Judge{ //处理考试结束 public handEndExam = async ()=>{ - const {isExam,judgeUI,endExam,avPlayer} = this; - + const {endExam,avPlayer} = this; avPlayer.playAudio(['km2/exam_waiting.mp3'],true) this.isEnd = true + // 获取最后一次心跳 const bytes = await this.getMessageHeartbeat(true); const singlePlay = globalThis.singlePlay singlePlay || globalThis.judgeUdp.send(bytes) - //结束评判函数 + // c++调用考试结束 await examJudgeEndExam(); globalThis.isJudge = false await endExam() @@ -333,10 +335,14 @@ export default class Judge{ const markRuleListObj = this.judgeUI.markRuleListObj; const thisMark = markRuleListObj[code] return { + //扣分描述 desc: thisMark.markshow, + //扣分分数 score: thisMark.markreal, markcatalog: thisMark.markcatalog, + // 扣分编码 markserial:thisMark.markserial, + // 扣分序号 kfxh:thisMark.kfxh } } @@ -412,7 +418,7 @@ export default class Judge{ xtlb:'17',jkxlh:serialNumber,jkid:'17C53', drvexam:{ lsh,kskm:examSubject, - // 通用评判科二10000,科三30000 + //TODO 通用评判科二10000,科三30000 ksxm:project?project.projectCodeCenter:10000, kfxm:kf.markcatalog, kfxmmx:`${ksxm},${kf.markserial}`, @@ -486,6 +492,7 @@ export default class Judge{ if(!isManual){ if(totalScore < 80){ judgeUI.loadingPopupVisible = true + //考试次数为1次 if(kssycs == 1){ avPlayer.playAudio(['km2/unqualified_one.wav'],true) }else{ @@ -648,7 +655,6 @@ export default class Judge{ let tempArr = []; arr.forEach(itemArr =>{ tempArr = tempArr.concat(itemArr)}) - this.serialIndex += 1; return Array2Byte(tempArr) } @@ -733,6 +739,7 @@ export default class Judge{ return sbxh } + //获取场地设备编码 getSbbm = (ksxm,xmxh) => { const {judgeUI} = this; const {cdsbInfoObj,projectsObj} = judgeUI; @@ -783,7 +790,6 @@ export default class Judge{ return modelData } - private judgeUI private fileLog private totalScore:number diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judge-real.ts b/entry/src/main/ets/pages/judgeSDK/utils/judge-real.ts index 53bb200..5464b52 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judge-real.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judge-real.ts @@ -1,18 +1,10 @@ import { - examJudgeSetLogCallback, - examJudgeBeginExam, - examJudgeInit, - examJudgeRealExam, - examJudgeSetRealExamCallback, examJudgeMapSetParam, - examJudgeMapSetDrawing, examJudgeMapSetScaling } from '../api/index' -import systemTime from '@ohos.systemDateTime'; import FileUtil from '../../../common/utils/File' import FileModel from './../utils/file-model' -import {testRealExam} from '../dataTest/index' const judgeTag = 'SURENJUN_JUDGE' diff --git a/entry/src/main/ets/pages/register.ets b/entry/src/main/ets/pages/register.ets index 22d41d2..aa03c87 100644 --- a/entry/src/main/ets/pages/register.ets +++ b/entry/src/main/ets/pages/register.ets @@ -3,7 +3,7 @@ import { getDeviceInfo} from '../common/service/terminalService' import { registrationDeviceNo } from '../api/checkCar' import { dateFormat} from '../common/utils/tools' import deviceManager from '@ohos.distributedHardware.deviceManager' -import { upDateTableConfig } from '../common/service/initable' +import { upDateTableByArray } from '../common/service/initable' import { voiceService } from '../common/service/voiceService' import promptAction from '@ohos.promptAction' @Entry @@ -107,7 +107,7 @@ struct Index { type:'1' } globalThis.deviceNo=this.ip - upDateTableConfig('DeviceInfoTable',[{deviceId:this.ip}]) + upDateTableByArray('DeviceInfoTable',[{deviceId:this.ip}]) registrationDeviceNo(param).then(res=>{ if(res.registrationDeviceNoRsp.head.resultCode=='0'){ promptAction.showToast({ From 848282fe043e0b3c875e1dbd10638915cbbb7d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwangzhongjie=E2=80=9D?= Date: Tue, 5 Mar 2024 15:44:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/UdpClient.ts | 7 +- .../ets/common/utils/UdpClientByCenter.ts | 6 +- entry/src/main/ets/pages/Index.ets | 8 +- entry/src/main/ets/pages/UserInfo.ets | 73 ++++++++++--------- entry/src/main/ets/pages/VideoConfig.ets | 51 ++++++++++--- .../compontents/faceCompareByhaikang.ets | 63 ++++++++++------ 6 files changed, 130 insertions(+), 78 deletions(-) diff --git a/entry/src/main/ets/common/utils/UdpClient.ts b/entry/src/main/ets/common/utils/UdpClient.ts index c941b92..2946d57 100644 --- a/entry/src/main/ets/common/utils/UdpClient.ts +++ b/entry/src/main/ets/common/utils/UdpClient.ts @@ -27,6 +27,7 @@ export default class UdpClient { private oppositeIpPort: string = '' private udp: any = null + private stashFn constructor(udplocalIp: string, udplocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) { this.localIp = udplocalIp @@ -72,7 +73,9 @@ export default class UdpClient { console.log(`${TAG} udp bind failed:${JSON.stringify(err)}`); }); } - + setMsgCallBack(callback){ + this.stashFn=callback + } sendMsg(msg: string) { let promise = this.udp.send({ data: msg, @@ -114,6 +117,8 @@ export default class UdpClient { if (strachArr[0] != '#DN_GD') { return } + this.stashFn(str) + this.stashFn=()=>{} callback(str) } else { callback('') diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index 6e9ccb9..499055c 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -161,12 +161,15 @@ export default class UdpClientByCenter { console.log(`${TAG} udpLine send fail:${JSON.stringify(err)}`); }); } - + setMsgCallBack(callback){ + this.stashFn=callback + } sendMsg(param,context?) { if(context){ this.context=context } this.sendId=param.id + console.log('sendMsg',JSON.stringify(param)) const msgData=this.setWholeMsg(param) // const msgData=this.setMsyBody('31','010000000000000') let promise = this.udp.send({ @@ -176,7 +179,6 @@ export default class UdpClientByCenter { port: parseInt(this.oppositeIpPort), } }); - this.stashFn=param.callback?param.callback:()=>{} promise.then(() => { if(param.sendCallback){ param.sendCallback() diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 86168f7..b8ae206 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -184,7 +184,8 @@ struct Index { for (let i = 0;i < str.length; i++) { tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) } - const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId} + const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRomId} + // globalThis.udpClient2.initHeartSendMsg(param,this.context) globalThis.udpClient2.sendMsg(param, this.context) } @@ -194,11 +195,10 @@ struct Index { getUDP() getUDP2() setInterval(() => { - setliushuiNum(this.context) - this.heartMsg(this.context) + setliushuiNum() + this.heartMsg() }, 1000) // 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) { diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 52d8993..2c9bafc 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -16,6 +16,7 @@ import WebRTCVoice from './webRTC/' import promptAction from '@ohos.promptAction' import { CandidateData, EmptyCandidateObject } from "../mock/CandidateData" import {string2Bytes} from '../common/utils/tools' +import { getSyncData } from '../common/service/initable' @Entry @Component struct UserInfo { @@ -69,8 +70,6 @@ struct UserInfo { @State grantDept: string = ''; @State effectDate: string = ''; @State interval: any = null; - @State interval2: any = null; - @State interval3: any = null; @State studentRefreshStatue: string = '0'; @State photo: string = 'data:image/bmp;base64,'; @State numCount: number = 0; @@ -80,21 +79,21 @@ struct UserInfo { subscriber; @State faceCatchImg: string = '' - onPageShow() { + async onPageShow() { //语音功能 - + const systemParms:any = await getSyncData('MA_SYSTEMPARM') + console.log('systemParms',systemParms.length) new WebRTCVoice(this.context); //初始化数据 this.initData() //身份证读卡器初始化 - this.openDeviceByIDCard() + // this.openDeviceByIDCard() // 如果是单机模式则模拟假数据 this.initSysset() initJudgeUdp() - this.interval=setInterval(()=>{ - this.heartMsg() - },1000) + this.heartMsg() + } //身份证读卡器初始化 openDeviceByIDCard(){ @@ -107,6 +106,9 @@ struct UserInfo { console.error("zzctest Failed to Open Device"); } } + stopDeviceById(){ + testNapi&&testNapi.StopReadCard() + } // 通过身份证获取当前学员 getCurrentStudent(id) { let flag = false @@ -122,7 +124,7 @@ struct UserInfo { // this.currentUser.kszp=this.photo+res.kszp // this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp if (globalThis.singlePlay) { - testNapi.StopReadCard(); + this.stopDeviceById() // globalThis.statue=4 router.pushUrl({ url: 'pages/Judge', @@ -224,15 +226,7 @@ struct UserInfo { } async heartMsg() { - const arr = [globalThis.signNum||0, globalThis.statue||1] - let tmpList = []; - tmpList.push(string2Bytes(arr[0], 1 * 8)[0]) - tmpList.push(string2Bytes(arr[1], 1 * 8)[0]) - const str =globalThis.lsh|| '0000000000000' - for (let i = 0;i < str.length; i++) { - tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0]) - } - const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId,callback:(val)=>{ + globalThis.udpClient2.setMsgCallBack((val)=>{ if(val.id=='32'){ globalThis.signNum=val.body[1] if(val.body[0]=='7'){ @@ -243,8 +237,7 @@ struct UserInfo { console.log('qkfnqkfn',val.body[0]) this.qkFn() } - }} - globalThis.udpClient2.sendMsg(param, this.context) + }) } getqkFn() { let tmpList = []; @@ -277,21 +270,28 @@ 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 faceParam = syssetParams.filter(sys => sys.v_no === '17') - that.FaceOpenStatue = faceParam?.[0]?.v_value || '0' + const faceParam = syssetParams.filter(sys => sys.v_no === '2313') + that.FaceOpenStatue =faceParam?.[0]?.v_value=='3'? '1':'0' + that.FaceOpenStatue = '0' + console.log('that.FaceOpenStatue',that.FaceOpenStatue) + // faceParam?.[0]?.v_value || + // 1身份证读卡器 2指纹 3人脸 + if(faceParam?.[0]?.v_value=='1'){ + that.openDeviceByIDCard() + } console.log('mmmmm',that.FaceOpenStatue) //0不自动更新 1自动更新(不限次数) 2没有考生更新2次 if (that.studentRefreshStatue == '2') { - clearInterval(that.interval2) - that.interval2 = setInterval(() => { + clearInterval(that.interval) + that.interval = setInterval(() => { if (that.dataList.length == 0 && that.numCount < 3) { that.numCount++ that.getExaminationStudentInfoFn() } }, 5000) } else if (that.studentRefreshStatue == '1') { - clearInterval(that.interval2) - that.interval2 = setInterval(() => { + clearInterval(that.interval) + that.interval = setInterval(() => { if (that.dataList.length == 0) { that.getExaminationStudentInfoFn() } @@ -303,6 +303,7 @@ struct UserInfo { } changeFaceCompareSuccess() { + globalThis.statue = 2 console.log('this.faceCompareSuces', this.faceCompareSucess, JSON.stringify(this.currentUser)) if (this.faceCompareSucess > 0) { this.sfbdinterfaceFn() @@ -334,12 +335,12 @@ struct UserInfo { if (!res) { this.dataList = [] this.currentUser = EmptyCandidateObject - console.log('currentUser', JSON.stringify(this.currentUser)) this.errorMsg = decodeURI(res.getExaminationStudentInfoRsp.head.resultMessage) return } let dataList = [] this.list = [] + for (let key in res.getExaminationStudentInfoRsp.body) { const a = res.getExaminationStudentInfoRsp.body[key] if (a instanceof Array) { @@ -438,7 +439,7 @@ struct UserInfo { ksxtbh: this.ksxtbh || '222', sfzmhm: this.currentUser.sfzmhm || '', ksysfzmhm: this.currentUser.ksy1sfzmhm || '', - zp: encodeURIComponent(this.faceCatchImg || ''), + zp: encodeURIComponent((this.faceCatchImg||this.currentUser.kszp.substr(22)) || ''), kssj: dateFormat(date) || '', kchp: decodeURI(plateNo), Ksy2sfzmhm: this.currentUser.ksy2sfzmhm || '' @@ -455,6 +456,7 @@ struct UserInfo { globalThis.lsh = this.currentUser.lsh globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm this.currentUser.id = '1' + console.log('codecode',code) if (code) { this.AccountTable.query('0', (result) => { if (result.length == 0) { @@ -466,7 +468,8 @@ struct UserInfo { url: 'pages/Judge', params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx } }, router.RouterMode.Single); - testNapi.StopReadCard(); + this.stopDeviceById() + }) }) } else { @@ -478,7 +481,7 @@ struct UserInfo { params: { examItems: examItems?.getExaminationItemRsp?.body?.ykxx } }, router.RouterMode.Single); globalThis.statue = 4 - testNapi.StopReadCard(); + this.stopDeviceById() }) }) } @@ -492,8 +495,8 @@ struct UserInfo { } outClick() { clearInterval(this.interval) - clearInterval(this.interval2) - testNapi.StopReadCard(); + this.stopDeviceById() + globalThis.udpClient2.setMsgCallBack(()=>{}) } // 几个按钮公共样式 @Styles @@ -646,7 +649,7 @@ struct UserInfo { router.pushUrl({ url: 'pages/Judge', }, router.RouterMode.Single); - testNapi.StopReadCard(); + this.stopDeviceById() }) }) } else { @@ -655,7 +658,7 @@ struct UserInfo { router.pushUrl({ url: 'pages/Judge', }, router.RouterMode.Single); - testNapi.StopReadCard(); + this.stopDeviceById() }) }) } @@ -678,8 +681,8 @@ struct UserInfo { faceCompareSucess: $faceCompareSucess, getqkFlag: $getqkFlag, faceCatchImg: $faceCatchImg, - lsh: globalThis.lsh, showFaceCompare: $showFaceCompare, + lsh: globalThis.lsh, }) } if (this.qkFlag) { diff --git a/entry/src/main/ets/pages/VideoConfig.ets b/entry/src/main/ets/pages/VideoConfig.ets index b5e8ab8..99084d6 100644 --- a/entry/src/main/ets/pages/VideoConfig.ets +++ b/entry/src/main/ets/pages/VideoConfig.ets @@ -5,6 +5,7 @@ import common from '@ohos.app.ability.common'; import promptAction from '@ohos.promptAction' import { startRecordVideo, endRecordVideo,takePhoto } from '../common/service/videoService' import configAddress from '../common/utils/FileConfig' +import util from '@ohos.util'; @Entry @Component struct Index { @@ -33,7 +34,7 @@ struct Index { shuiying: true, pztd: '2', ljlx: '', - ip: '192.168.7.112', + ip: '192.168.36.94', port: '554', userName: 'admin', pwd: '12345qwe', @@ -60,7 +61,7 @@ struct Index { shuiying: true, pztd: '2', ljlx: '', - ip: '192.168.7.112', + ip: '192.168.36.94', port: '554', userName: 'admin', pwd: '12345qwe', @@ -148,7 +149,9 @@ struct Index { } for (let i = 1; i <= 4; i++) { if (this.param['videoRecord'+i]) { - this.getfilehandleCode(i) + // setTimeout(()=>{ + this.getfilehandleCode(i) + // },500) } } promptAction.showToast({ @@ -163,6 +166,7 @@ struct Index { .margin({ bottom: 10 * this.ratio }) .onClick(() => { for (let i = 1; i <= 4; i++) { + console.log('rocord_handle',JSON.stringify(this.rocordHandleObj)) if (this.rocordHandleObj['rocord_handle'+i]) { endRecordVideo(this.rocordHandleObj['rocord_handle'+i]) this.rocordHandleObj['rocord_handle'+i] = -1 @@ -186,11 +190,31 @@ struct Index { }) return } - await takePhoto(this.param,this.context,0,'pz') - promptAction.showToast({ - message: '抓图完成', - duration: 3000 - }) + try{ + const buffer =await takePhoto(this.param,this.context,1,'pz/') + // let view: Uint8Array = new Uint8Array(buffer); // 使用Uint8Array读取arrayBuffer的数据 + // let textDecoder: util.TextDecoder = util.TextDecoder.create(); // 调用util模块的TextDecoder类 + // const str = textDecoder.decodeWithStream(view).trim(); // 对view解码 + // console.log("daihai base64 str = " + str); + // console.log("daihai base64 length = " + str.length); + promptAction.showToast({ + message: '抓图完成', + duration: 3000 + }) + // takePhoto(this.param,this.context,1,'pz/').then((data) => { + // console.log('daihai suc') + promptAction.showToast({ + message: '抓图完成', + duration: 3000 + }) + // }).catch((err) => { + // console.log('daihai err: ' + err) + // }) + + }catch (error){ + console.log('daihai',error) + } + }) .margin({ bottom: 10 * this.ratio }) }.margin({ right: 38 * this.ratio, top: 110 * this.ratio }) @@ -371,7 +395,7 @@ struct Index { .onChange((value: string) => { this.param.ip = value }) - TextInput({ text: this.param['td'+index+1], controller: this.inputController }) + TextInput({ text: this.param['td'+(Number(index)+1)], controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(96 * this.ratio) @@ -380,7 +404,7 @@ struct Index { .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize * this.ratio) .onChange((value: string) => { - this.param.td1 = value + this.param['td'+(Number(index)+1)] = value }) TextInput({ text: this.param.userName, controller: this.inputController }) .type(InputType.Normal) @@ -589,7 +613,7 @@ struct Index { .width('100%') .height(395 * this.ratio) .backgroundColor('#CCC4B8') - .position({ x: 0, y: 460 * this.ratio }) + .position({ x: 0, y: 260 * this.ratio }) .border({ radius: { topLeft: 24 * this.ratio, topRight: 24 * this.ratio } }) } @@ -604,7 +628,7 @@ struct Index { } async getfilehandleCode(td){ const record_handle = await startRecordVideo(this.param,td,this.context,'lp') - this.rocordHandleObj['rocord_handle1'+td]=record_handle + this.rocordHandleObj['rocord_handle'+td]=record_handle } outClick() { this.openFlag = false @@ -622,6 +646,9 @@ struct Index { async writeConfig() { this.oldParam = JSON.parse(JSON.stringify(this.param)) + this.videoArr=JSON.parse(JSON.stringify(this.videoArr)) + console.log('videoArr',JSON.stringify(this.videoArr)) + console.log('videoArr2',JSON.stringify(this.param)) const folderPath = await this.fileUtil.initFolder(`/config`); this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite') this.showFlag = false diff --git a/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets b/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets index 8baddb2..72952bb 100644 --- a/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets +++ b/entry/src/main/ets/pages/compontents/faceCompareByhaikang.ets @@ -23,13 +23,14 @@ struct FaceCompare { @Prop lsh: string; @Prop firstImage: string; @Link faceCompareSucess: number; + @Link showFaceCompare: boolean; @Link getqkFlag: boolean; @Link faceCatchImg: string; @State imageThumbnail: string = ''; private times = 1; //人脸比对失败次数, 超过3次将不会自动比对,需要点击重新打开重新触发 private vocObj = null; @State callBackFlag: boolean = false; - @State @Watch('clearIntervalFn') showFaceCompare: Boolean = false; + @State @Watch('clearIntervalFn') showFaceCompareFlag: Boolean = false; @State video_url: string = 'rtsp://admin:12345qwe@192.168.5.41:8000/h264/ch2/main/av_stream' @State previewUri: Resource = $r('app.media.2_nor') @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @@ -87,6 +88,7 @@ struct FaceCompare { .width('48%') .height('100%') + Row() { Image(this.firstImage) .width('100%') @@ -155,8 +157,8 @@ struct FaceCompare { this.controller.stop() this.vocObj && this.vocObj.releasePlayer() this.showFaceCompare = !this.showFaceCompare + this.showFaceCompareFlag=!this.showFaceCompareFlag this.faceCompareSucess = -1 - }) } .width('100%') @@ -193,7 +195,11 @@ struct FaceCompare { } async faceComparFn() { - const result = await takePhoto(this.param, this.context, 1,'jt') + console.log('mmmmm0',1) + + const result = await takePhoto(this.param, this.context, 1,'jt/') + console.log('mmmmm8',9) + faceCompare({ sfzh: this.sfzh, firstImage: this.firstImage.substr(22), @@ -201,9 +207,12 @@ struct FaceCompare { type: 2, verifyType: 1 }).then(res => { + console.log('mmmmm8',res) + if (res) { this.controller.stop() this.showFaceCompare = !this.showFaceCompare + this.showFaceCompareFlag=!this.showFaceCompareFlag this.faceCompareSucess = 1; // this.faceCatchImg = result this.vocObj.playAudio({ @@ -239,6 +248,7 @@ struct FaceCompare { this.callBackFlag = true } } + globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context) this.interval = setInterval(() => { if (this.callBackFlag) { const param2 = { @@ -246,31 +256,32 @@ struct FaceCompare { list: tmpList, carNo: globalThis.carInfo.carNo, placeId: globalThis.carInfo.examinationRoomId, - callback: (val) => { - if (val.id == '48') { - if (val.body[13] == '1') { - this.showFaceCompare = !this.showFaceCompare - this.vocObj && this.vocObj.releasePlayer() - this.faceCompareSucess = 1 - clearInterval(this.interval) - } else if (val.body[13] == '0' && this.callBackFlag) { - globalThis.statue = 2 - this.vocObj && this.vocObj.playAudio({ - type: 1, - name: 'face_chekc_fail.wav' - }) - } - } - } } globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param2, this.context) } }, 1000) - globalThis.udpClient2 && globalThis.udpClient2.sendMsg(param, this.context) + globalThis.udpClient2.setMsgCallBack((val) => { + if (val.id == '48') { + if (val.body[13] == '1') { + this.showFaceCompareFlag=!this.showFaceCompareFlag + this.showFaceCompare = !this.showFaceCompare + this.vocObj && this.vocObj.releasePlayer() + this.faceCompareSucess = 1 + clearInterval(this.interval) + } else if (val.body[13] == '0' && this.callBackFlag) { + globalThis.statue = 2 + this.vocObj && this.vocObj.playAudio({ + type: 1, + name: 'face_chekc_fail.wav' + }) + } + } + }) } async getVideoConfig() { + console.log('faceEnterIn') this.vocObj = new voiceService(async (status, val, next) => { if (status == 'idle') { if (val == 'face_check.mp3' || val == 'face_fail.mp3') { @@ -289,6 +300,7 @@ struct FaceCompare { } } else if (val == 'yzcg.wav') { this.showFaceCompare = !this.showFaceCompare + this.showFaceCompareFlag=!this.showFaceCompareFlag globalThis.statue = 4 this.faceCompareSucess = 1; this.vocObj && this.vocObj.releasePlayer() @@ -297,11 +309,14 @@ struct FaceCompare { this.vocObj && this.vocObj.releasePlayer() this.faceCompareSucess = -1 this.showFaceCompare = !this.showFaceCompare + this.showFaceCompareFlag=!this.showFaceCompareFlag } } }); const data = await this.fileUtil.readFile(configAddress.comoonfileWriteAddress + '/config/config3.txt'); + console.log('faceEnterIn,data',data) + setTimeout(() => { this.vocObj && this.vocObj.playAudio({ type: 1, @@ -310,10 +325,10 @@ struct FaceCompare { }, 1000) this.param = JSON.parse(data) this.param.userName = JSON.parse(data).userName - this.param.ip = JSON.parse(data).ip - this.param.pwd = JSON.parse(data).pwd - this.param.port = JSON.parse(data).port - this.param.rlls = JSON.parse(data).rlls + this.param.ip = this.param.ip + this.param.pwd = this.param.pwd + this.param.port = this.param.port + this.param.rlls = this.param.rlls this.controller.start() }