main #2

Merged
wangzhongjie merged 4 commits from harmony_car/subject-two:main into main 2024-03-05 15:52:04 +08:00
19 changed files with 732 additions and 1337 deletions
Showing only changes of commit 0fe5385625 - Show all commits

View File

@ -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')

View File

@ -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)
}

View File

@ -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(() => {

View File

@ -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;

View File

@ -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<videoPlayRes>(async (reslove,reject)=>{
export async function startRecordVideo(param, td, context, dir) {
return new Promise<videoPlayRes>((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=0base64
*/
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
}

View File

@ -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()

View File

@ -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'&&param.callback){
param.callback()
if(param.sendCallback){
param.sendCallback()
}
// if(this.sendId=='46'&&param.callback){
// param.callback()
// }
console.log(`${TAG} udp send success:`);
}).catch(err => {
console.log(`${TAG} udp send fail:${JSON.stringify(err)}`);

View File

@ -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() {

View File

@ -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() {

View File

@ -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);

View File

@ -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<any>)=>{
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(){
}
}

View File

@ -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()
}
})
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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<string> = [
'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

View File

@ -1,5 +1,6 @@
import libJudgeSdk from 'libJudgeSdk.so'
// import libJudgeSdk from '@ohos.judgesdk'
/**
*
* @date 2023/04/10

View File

@ -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'},

View File

@ -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

View File

@ -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'

View File

@ -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({