Fix file paths and update versions

This commit is contained in:
“wangzhongjie” 2024-01-31 14:42:14 +08:00
parent 74bcb8f05c
commit 93f87208f0
17 changed files with 497 additions and 103 deletions

View File

@ -558,8 +558,8 @@ export async function upDataZhongxinginitialization(){
"carId": globalThis.carInfo?.carId, // 表名
"examinationRoomId": globalThis.carInfo?.examinationRoomId, //考试平台kdid
videoVersion:'1.0',
judgeVersion:'2022.03.17.1',
shellVersion:'2022.03.14.01'
judgeVersion:'2024.11.22.14',
shellVersion:'2024.11.22.14'
}
let res: any = await initialization(str)
if(!res){

View File

@ -4,15 +4,14 @@ import { dateFormat} from '../utils/tools'
//获取设备信息
export async function getDeviceInfo() {
globalThis.deviceNo = 'J43405J003101'; //设备mac
// globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac
// globalThis.deviceNo = 'J43405J003101'; //设备mac
globalThis.deviceNo = 'FE-FC-FE-7C-5C-77'; //设备mac
globalThis.diskId = '1231231231'; //硬盘号
globalThis.hasAuth = true;
return null
}
//获取考车信息
export async function getCarInfo() {
let date = new Date();

View File

@ -23,7 +23,7 @@ export default class FileUtil{
}
/*
* @desc
* @desc
*
*/
public initFolder = async (folderPath:string) => {
@ -36,8 +36,6 @@ export default class FileUtil{
const isExit = fs.accessSync(path);
if(!isExit){
fs.mkdirSync(path)
console.error(LOGTAG,path)
const isExit = fs.accessSync(path);
}
}));
return path;

View File

@ -4,8 +4,8 @@ import prompt from '@ohos.prompt'
import { sendGreen } from '../../pages/judgeSDK/utils/judge-common';
const config = {
// host: 'http://112.80.35.83:11052',
host: 'http://192.168.36.2:8083',
host: 'http://112.80.35.83:11052',
// host: 'http://192.168.36.2:8083',
}
let httpRequest = http.createHttp();

View File

@ -53,10 +53,12 @@ export function dateVersionFormat(t) {
return year + "." + fill(month) + "." + fill(day) + "." + fill(hours);
}
enum timeType{
fulltime = 1
}
//获取当前时间并转化
export async function getCurrentTime(type?:1):Promise<string> {
export async function getCurrentTime(type?:timeType):Promise<string> {
const date = await systemTime.getDate();
const year = date.getFullYear();
@ -133,13 +135,13 @@ export function chunkArr (arr, size:number) {
//对象深拷贝
export function deepClone(target) {
// 如果是对象且不是原始值null
if (typeof target === 'object' && target !== 'null') { //注解一
if (typeof target === 'object' && target !== 'null') {
// 创建容器
const result = Array.isArray(target) ? [] : {}; //注解三
const result = Array.isArray(target) ? [] : {};
const keys = Object.keys(target); //注解二
// Object.keys()会过滤掉原型链上的属性
keys.forEach(key => {
result[key] = deepClone(target[key]) // 注解三
result[key] = deepClone(target[key])
})
return result;
}

View File

@ -28,8 +28,8 @@ export default class EntryAbility extends UIAbility {
globalThis.examinerInfo = {}
globalThis.deviceNo = '';
globalThis.hasAuth = false
// globalThis.version = '2024.11.22.14'
globalThis.version = '2022.03.14.01'
globalThis.version = '2024.11.22.14'
// globalThis.version = '2022.03.14.01'
globalThis.context = this.context;
globalThis.pathDir = this.context.filesDir;

View File

@ -3,7 +3,7 @@ import common from '@ohos.app.ability.common';
import router from '@ohos.router'
import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'
import { setCurrentTime } from '../common/service/timeService'
import { string2Bytes } from '../common/utils/tools'
import {Array2Byte} from '../common/utils/tools'
import {
getDataBaseTable,
upDateTable,
@ -15,12 +15,22 @@ import {
} from '../common/service/initable'
import prompt from '@ohos.prompt'
import { dateFormat } from '../common/utils/tools'
import deviceManager from '@ohos.distributedHardware.deviceManager'
import AccountTable from '../common/database/tables/AccountTable';
import MA_SYSSET from '../common/constants/MA_SYSSET';
import { getUDP, getUDP2 } from '../common/utils/GlobleUdp'
import {initJudgeUdp} from '../common/utils/UdpJudge'
import { getTCP } from '../common/utils/GlobleTcp'
import { voiceService } from '../common/service/voiceService'
import testNapi from '@ohos.hiserialsdk'
import TcpClient from '../common/utils/TcpClient';
import Router from '@system.router'
import socket from '@ohos.net.socket';
import fs from '@ohos.file.fs'
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import FileUtil from '../common/utils/File'
@Entry
@Component
struct Index {
@ -37,6 +47,7 @@ struct Index {
@State devPath: string = "/dev/ttyS0"
@State fd: number = -1;
private context = getContext(this) as common.UIAbilityContext;
build() {
Column() {
Column() {
@ -62,6 +73,7 @@ struct Index {
// getSyncData('MA_SYSSET')
router.back()
// this.url = 'back'
// app.terminate()
})
@ -75,6 +87,10 @@ struct Index {
Row() {
if (!this.isSingle) {
Image($r('app.media.index_lw')).width('30.5%').height('74%').onClick(() => {
// this.vocObj.playAudio({
// type: 1,
// name: 'button_media.wav'
// })
if (this.loading) {
return
}
@ -89,7 +105,9 @@ struct Index {
this.upDateTable()
}else{
this.getCenterDataTable()
}
})
}
if (this.isSingle) {
@ -190,25 +208,81 @@ struct Index {
aboutToAppear() {
this.angle = 0
this.loading = false
// this.vocObj = new voiceService(async (status, val) => {
// if (status == 'idle') {
// if (this.url == 'back') {
// router.back()
// // that.udpClient.sendMsg('111')
// } else {
// router.pushUrl({
// url: this.url,
// });
// }
// }
// });
}
Array2Byte(array) {
var buf = new ArrayBuffer(array.length);
var view = new Uint8Array(buf);
for (var i = 0; i != array.length; ++i)
{
view[i] = array[i] & 0xFF;
}
return view;
}
openChuankouMsg() {
this.fd = testNapi.SerialOpen(this.devPath);
}
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;
}
//补0
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;
}
async heartMsg(context) {
const fileUtil = new FileUtil(context)
const fileData = await fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/liushui.txt');
let res = fs.accessSync('/mnt/hmdfs/100/account/device_view/localfiles/files/config/liushui.txt');
if(res&&JSON.stringify(fileData).indexOf('u0000')<0){
const date = new Date()
const time1 = JSON.parse(fileData).date.split(' ')[0]
const time2 = dateFormat(date).split(' ')[0]
if (time1 == time2) {
const date = new Date()
const param = {
date: dateFormat(date),
value: Number(JSON.parse(fileData).value) + 1
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
} else {
// TODO
return
if (res) {
if(JSON.stringify(fileData).indexOf('u0000')>=0){
const date = new Date()
const param = {
date: dateFormat(date),
@ -216,8 +290,30 @@ struct Index {
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
}else{
const date = new Date()
const time1 = JSON.parse(fileData).date.split(' ')[0]
const time2 = dateFormat(date).split(' ')[0]
if (time1 == time2) {
const date = new Date()
const param = {
date: dateFormat(date),
value: Number(JSON.parse(fileData).value) + 1
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
} else {
const date = new Date()
const param = {
date: dateFormat(date),
value: 0
}
const folderPath = await fileUtil.initFolder(`/config`);
fileUtil.addFile(`${folderPath}/liushui.txt`, JSON.stringify(param))
}
}
}else{
}else
{
const date = new Date()
const param = {
date: dateFormat(date),
@ -228,27 +324,35 @@ struct Index {
}
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])
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.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])
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
// const str ='1111160366580'
// 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: 489, placeId: 62 }
const param= {id: 31,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
globalThis.udpClient2.sendMsg(param, this.context)
}
onPageShow() {
this.loading = false
this.initParams()
getUDP()
getUDP2()
setInterval(() => {
this.heartMsg(this.context)
}, 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) {
globalThis.singlePlay = false
@ -259,6 +363,14 @@ struct Index {
}
Array2Byte(array) {
var buf = new ArrayBuffer(array.length);
var view = new Uint8Array(buf);
for (var i = 0; i != array.length; ++i) {
view[i] = array[i] & 0xFF;
}
return view;
}
async initParams() {
this.loading=false
@ -270,6 +382,11 @@ struct Index {
this.version = globalThis.version;
this.hasAuth = globalThis.hasAuth;
initJudgeUdp()
// await this.getDataBaseTableFn()
//下载模型
// await this.getModel()
// const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]
// globalThis.udpClientByTopLine.sendMsg(this.Array2Byte(arr).buffer)
}
getDeviceId() {
@ -280,6 +397,16 @@ struct Index {
this.deviceId = result[0].deviceId
resolve(result[0].deviceId)
} else {
// deviceManager.createDeviceManager('com.example.udptest', (error, value) => {
// if (error) {
// console.error('createDeviceManager failed.');
// return;
// }
// let dvMgrObj = value;
// globalThis.deviceNo=dvMgrObj.getLocalDeviceInfoSync().deviceName
// this.deviceId=globalThis.deviceNo
// resolve(dvMgrObj.getLocalDeviceInfoSync().deviceName)
// });
resolve('')
}
})
@ -293,6 +420,28 @@ struct Index {
await getEsCarModel(context)
}
async getDataBaseTableFn() {
// getDataBaseTable({ tableName: 'MA_MARKRULE' })
// getDataBaseTable({ tableName: 'MA_SYSTEMPARM' })
// await getDataBaseTable({ tableName: 'MA_SYSSET' })
// await getMySystemSetTable({ tableName: 'MA_SYSSET' })
//
// await getDataBaseTable({ tableName: 'MA_MAP_COLLECT' })
// await getDataBaseTable({ tableName: 'MA_MAP_COLLECT_SHAPE' })
// await getDataBaseTable({ tableName: 'MA_MAP_ITEMCLASS' })
// await getDataBaseTable({ tableName: 'MA_MAP_POINT' })
// await getDataBaseTable({ tableName: 'MA_MAP_POINT_ITEM' })
// await getDataBaseTable({ tableName: 'MA_MAP_ROAD' })
// await getDataBaseTable({ tableName: 'MA_MAP_ROAD_LANE' })
// await getDataBaseTable({ tableName: 'MA_MAP_SUBITEM' })
// await getDataBaseTable({ tableName: 'ES_CARINFO' })
// await getDataBaseTable({ tableName: 'ES_EXAMPOINTDETAIL' })
// await getDataBaseTable({ tableName: 'MA_MARKRULESET' })
// await getDataBaseTable({ tableName: 'ES_CAR_VIDEO_PARAMETER' })
// await getDataBaseTable({ tableName: 'MA_CDSBINFO' })
// await getDataBaseTable({ tableName: 'MA_ITEMINFO' })
// await getDataBaseTable({ tableName: 'MA_T_CARPARMSET' })
}
async getCenterDataTable() {
const flag= await upDataZhongxinginitialization()
@ -320,8 +469,17 @@ struct Index {
// getSyncData('MA_SYSSET')
getDataBaseTable({ tableName: 'MA_SYSSET' })
})
// array.map((res, i) => {
// db.deleteData(res, async () => {
// if (i == array.length - 1) {
// await getDataBaseTable({ tableName: 'MA_SYSSET' })
// // await getMySystemSetTable({ tableName: 'MA_SYSSET' })
// }
// });
// })
} else {
await getDataBaseTable({ tableName: 'MA_SYSSET' })
// await getMySystemSetTable({ tableName: 'MA_SYSSET' })
}
// console.log(markRuleParams)
})
@ -372,10 +530,46 @@ struct Index {
return
}
}
this.loading = false
// await getSyncData('MA_MARKRULE')
// await getSyncData('MA_SYSTEMPARM')
// await getSyncData('MA_MAP_COLLECT')
// await getSyncData('MA_MAP_COLLECT_SHAPE')
// await getSyncData('MA_MAP_ITEMCLASS')
// await getSyncData('MA_MAP_POINT')
// await getSyncData('MA_SYSTEMPARM')
// await getSyncData('MA_MAP_POINT_ITEM')
// await getSyncData('MA_MAP_POINT')
// await getSyncData('MA_MAP_POINT_ITEM')
// await getSyncData('MA_MAP_ROAD')
// await getSyncData('MA_MAP_ROAD_LANE')
// await getSyncData('MA_MAP_SUBITEM')
// await getSyncData('ES_CARINFO')
// await getSyncData('ES_EXAMPOINTDETAIL')
// await getSyncData('MA_CDSBINFO')
// await getSyncData('MA_T_CARPARMSET')
// if(!flag){
router.pushUrl({
url: 'pages/ExaminerLogin',
}, router.RouterMode.Single);
// return
// }
// await upDateTable({ tableName: 'MA_SYSSET' })
}
termialCheck() {
// if(!globalThis.deviceNo) {
// prompt.showToast({
// message: '未能查询到当前车辆信息, 请先注册该车辆, 或者检查网络是否连接正常!',
// duration: 3000
// });
//
// return false
// }
return true
}
}

View File

@ -62,7 +62,6 @@ struct Index {
await this.initSysset();
await this.initCDSBInfo()
const {name,idCard,lsh,kszp} = this;
const fileLog = new FileLog(this.context);
@ -72,7 +71,8 @@ struct Index {
//断点续考
await this.goDdxkItems()
// //初始化评判
//初始化评判
const judge = await this.initJudge(fileLog);
this.judge = judge
}
@ -123,9 +123,11 @@ struct Index {
//@ts-ignore
const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901');
this.serialNumber = (serialNumberArr[0] && serialNumberArr[0].v_value) || '123456'
// 211603660671
//TODO 杭州用到的特殊评判参数 211603660671
const judgeNumbers = ['211','603','660','671','606'];
const judgeConfig = []
//@ts-ignore
syssetParams.forEach((sys)=>{
if(judgeNumbers.includes(sys.v_no)){
@ -210,31 +212,6 @@ struct Index {
})
}
//获取项目信息
async initProjectInfo(){
const systemParamsArr = await getSyncData('MA_SYSTEMPARM')
const itemInfoArr = await getSyncData('MA_ITEMINFO')
//@ts-ignore
const filterProjectsArr = systemParamsArr.filter(item => item.no1 == 6)
testAllitems.map(project => {
//TODO 临时代码
const currentProject = {
name:(project.name),
abbreviation:(project.abbreviation),
projectCode:(project.projectCode),
projectCodeCenter:(project.projectCodeCenter),
sbxh:project.type
// type:project.type
}
this.projectsObj[project.projectCode] = currentProject
this.projectsCenterObj[project.projectCodeCenter] = currentProject
return currentProject
});
//@ts-ignore
//TODO 临时代码待替换
this.projects = testUIAllitems
}
// 评判相关初始化
async initJudge(fileLog){
const judge = new Judge(this,fileLog);
@ -246,11 +223,14 @@ struct Index {
});
return judge
}
// 断点续考判断
async goDdxkItems(){
//断点续考判断
let currentParams:any = router.getParams();
const examItems:string = currentParams?.examItems;
// 2024-01-03 16:29:26;0;20300,;2,4`^;null;
if(examItems !== '' && examItems !== undefined){
const examItemsArrs = examItems.split(';');
const startTime = examItemsArrs[0]

View File

@ -1,15 +1,30 @@
//@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 {string2Bytes} from '../../common/utils/tools'
// import MediaModel from '../../common/utils/MediaModel';
let previewWidth;
let previewHeight;
const PERMISSIONS: Array<string> = [
'ohos.permission.CAMERA']
@Component
struct FaceCompare {
constructor() {
@ -32,7 +47,9 @@ struct FaceCompare {
@State callBackFlag:boolean=false;
@State @Watch('changefaceCompareSucess') showFaceCompare2: Boolean = false;
private surfaceId: string = '';
@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
@ -41,7 +58,7 @@ struct FaceCompare {
@State signNum: number = 0;
private fileUtil: FileUtil
private interval: any
// private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext)
private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext)
private fd: number = -1;
@State param: VideoConfig = {
spls: '',
@ -211,11 +228,23 @@ struct FaceCompare {
}
getqkFn(){
let tmpList = [];
tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0])
// 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}
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;
@ -229,6 +258,7 @@ struct FaceCompare {
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);
@ -304,7 +334,7 @@ struct FaceCompare {
let tmpList=[]
const str =this.lsh
for (let i = 0;i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
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')
@ -461,7 +491,50 @@ struct FaceCompare {
}
})
}
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;
}
// 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();
}

View File

@ -5,7 +5,6 @@ import { voiceService } from '../../common/service/voiceService'
import prompt from '@ohos.prompt'
import SerialPortClient from '../../common/utils/SerialPortClient'
import RealTime from '../compontents/judge/real-time'
@Component
struct SignDisplayCom {
constructor() {

View File

@ -12,7 +12,7 @@ interface Params{
rlls:string
}
export default class PhotoModel{
export default class FilePhoto{
private params:Params
private context:any

View File

@ -111,11 +111,11 @@ export default class JudgeData{
ljmc:p[24], lcmc:0, csbzh:p[32], csbyh:p[30], csbyq:p[31], csbzq:p[29], zy:0, tbp:0, hsj:0, dcj:0, gx:0, yl:0
},
gps:{
//TODO 办卡类型 定位差分状态
//办卡类型 定位差分状态
bklx:p[56], dwzt:p[83],
//@ts-ignore 角度差分状态
jdzt:p[92].split('-')[0]*1,
//TODO gps数据
//gps数据
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
sj:time, jd:p[96], wd:p[95], hxj:p[90], fyj:p[91], hbg:p[85], gdc:p[86], sd:p[97],
//龄期 经度因子 纬度因子 定位搜星数

View File

@ -17,10 +17,9 @@ export default class JudgeTask{
try {
await currentTask();
}catch (e){
// TODO 优化
console.info(TAG,'鸿蒙:过程数据接口解析错误')
console.info(TAG,'过程数据接口解析错误')
prompt.showToast({
message: '鸿蒙:过程数据接口解析错误',
message: '过程数据接口解析错误',
duration: 3000
});
}
@ -31,12 +30,12 @@ export default class JudgeTask{
this.status = 'end'
}
}
addTask = async (fn) =>{
this.queue.push(fn);
if(this.status == 'end' && this.queue.length === 1){
await this.executeQueue();
}
}
}

View File

@ -48,7 +48,6 @@ const judgeTag = 'SURENJUN_JUDGE'
export default class Judge{
constructor(judgeUI,fileLog) {
this.totalScore = 0;
this.serialIndex = 1;
this.judgeUI = judgeUI
this.fileLog = fileLog;
@ -67,11 +66,9 @@ export default class Judge{
this.xmmcCode = '';
this.carztStr = '';
this.allKm2ItemsObj = {};
this.isTrajectoryOpen = false;
this.modelPath = 'models/model_enc'
this.trajectoryPath = '/logs/2024_01_18/2230201333925_330802200407086520_吴雪娥_2024_01_18_10_39_40/judge_exam_data.txt';
//1234236633488_679417917543435904_尹立曙_2024_01_15_19_27_56
//2230201333925_330802200407086520_吴雪娥_2024_01_18_10_39_40
this.isTrajectoryOpen = true;
this.trajectoryPath = '/logs/2024_01_24/2024_01_24_11_30_06_2210707689316_620502199005070478_马鸣五/judge_exam_data.txt';
this.isExam = !globalThis.singlePlay;
const {projectsCenterObj} = judgeUI
@ -113,10 +110,12 @@ export default class Judge{
//日志回调
console.info(judgeTag,'1.进入评判入口')
await examJudgeSetLogCallback(3, async (level, info,len)=>{
console.log('评判日志:' + info)
await fileLog.setExamJudgeLogData(info);
})
console.info(judgeTag,'2.注册日志回调完成')
//相关评判初始化只做一次
@ -135,6 +134,7 @@ export default class Judge{
const initInfo = await this.getJudgeInitData();
await fileLog.setExamJudgeData(initInfo)
}
globalThis.isJudge = true
// 2.评判过程回调
await examJudgeSetRealExamCallback(async (strData,len)=>{
@ -159,7 +159,6 @@ export default class Judge{
await examJudgeBeginExam(beginExamInfo);
console.info(judgeTag,'6.开始考试注册完成')
// sendGreen()
//实时plc数据信号
// let open = true;
if(isTrajectoryOpen){
@ -174,7 +173,6 @@ export default class Judge{
clearInterval(judgeTimer)
return
}
const {totalScore} = this;
// 4.过程数据
this.tempData = msg
this.plcData= msg
@ -193,7 +191,6 @@ export default class Judge{
return
}
const plcData = await getPlcData(msg);
const {totalScore} = this;
// 4.过程数据
await fileLog.setExamJudgeData(plcData)
await examJudgeRealExam(plcData)
@ -282,7 +279,7 @@ export default class Judge{
});
const copyProjectsObj = this.judgeUI.projectsObj;
//语音播报 & 发送中心接口
//语音播报
this.goVoiceAnnounce(event,xmdm, this.kfArr,xmjs)
judgeUI.projectsObj = deepClone(copyProjectsObj)
}
@ -365,7 +362,7 @@ export default class Judge{
}
}
//当前项目转换
// 当前项目转换
getDqxmStr = (type) => {
const projectsObj = this.judgeUI.projectsObj
if(projectsObj){
@ -616,7 +613,6 @@ export default class Judge{
this.isJudgeDisConnect = true;
}
const isJudgeDisConnect = this.isJudgeDisConnect;
// isJudgeDisConnect ? fileLog.setExamJudgeDisWuxiProgressData(data) : fileLog.setExamJudgeWuxiData(data)
let toast = '';
switch (code){
case -1:toast = '无当前科目考试信息';break;
@ -926,11 +922,11 @@ export default class Judge{
ljmc:p[24], lcmc:0, csbzh:p[32], csbyh:p[30], csbyq:p[31], csbzq:p[29], zy:0, tbp:0, hsj:0, dcj:0, gx:0, yl:0
},
gps:{
//TODO 办卡类型 定位差分状态
//办卡类型 定位差分状态
bklx:p[56], dwzt:p[83],
//@ts-ignore 角度差分状态
jdzt:p[92].split('-')[0]*1,
//TODO gps数据
//gps数据
//gps时间 经度 纬度 航向角 俯仰角 海拔高 高度差 速度
sj:time, jd:p[96], wd:p[95], hxj:p[90], fyj:p[91], hbg:p[85], gdc:p[86], sd:p[97],
//龄期 经度因子 纬度因子 定位搜星数
@ -1064,7 +1060,6 @@ export default class Judge{
//考试是否结束了
private isEnd:boolean
//UDP服务序列号
private serialNumber:number
private serialIndex:number
private fileUtil:FileUtil
private judgeTask:JudgeTask

View File

@ -62,12 +62,6 @@ export default class FileLog {
await fileUtil.editFile(`${folderPath}/wuxi_dis_progress_data.txt`,str);
}
// // 读取断点续考无锡过程数据
// public readExamJudgeDisWuxiProgressData = async () =>{
// const {fileUtil,folderPath} = this;
// await fileUtil.readFile(`${folderPath}/wuxi_dis_progress_data.txt`);
// }
// plc文件数据
public setPlcProgressData = async (str:string) => {
const {fileUtil,folderPath} = this;

View File

@ -12,7 +12,7 @@ interface Params{
rlls:string
}
export default class PhotoModel{
export default class FilePhoto{
private params:Params
private context:any
@ -41,6 +41,7 @@ export default class PhotoModel{
let mediaType = mediaLibrary.MediaType.IMAGE;
let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE;
const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS);
return new Promise(async (resolve)=>{
mediaTest.createAsset(mediaType, 'judge_face.jpg', path,(error,asset)=>{
asset.open('rw', (error, fd) => {

View File

@ -1,4 +1,6 @@
import { getExaminationItem, getExaminationStudentInfo, examinationStuAbsent,getPhotosForOther } from '../api/userInfo'
import { voiceService } from '../common/service/voiceService'
import router from '@ohos.router'
import TopLogo from './compontents/topLogo'
import Md5 from '../common/utils/md5';
@ -7,16 +9,22 @@ import USER from '../common/constants/USER';
import { dateFormat,getCurrentTime } from '../common/utils/tools';
import MA_SYSSET from '../common//constants/MA_SYSSET';
import FaceCompare from './compontents/faceCompareByhaikang'
import ethernet from '@ohos.net.ethernet';
import prompt from '@ohos.prompt'
import {initJudgeUdp} from '../common/utils/UdpJudge'
// import testNapi from "@ohos.idcard";
import CommonEvent from '@ohos.commonEventManager';
// @ts-ignore
import {writeObjectOut} from '../api/judge'
import testNapi from "@ohos.idcard";
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fs from '@ohos.file.fs'
import FileUtil from '../common/utils/File'
import common from '@ohos.app.ability.common';
import onvifclient from '@ohos.onvifclient';
import util from '@ohos.util';
import { VideoConfig } from './interfaces'
import WebRTCVoice from './webRTC/'
import {string2Bytes} from '../common/utils/tools'
@Entry
@Component
struct Index {
@ -95,6 +103,7 @@ struct Index {
@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;
@ -143,6 +152,8 @@ struct Index {
this.numCount=0
const fileUtil = new FileUtil(this.context)
this.fileUtil = fileUtil
globalThis.udpClient2&&globalThis.udpClient2.onMessage((val)=>{
console.log('valvaltotol2',val.id,val.body,val.length)
@ -156,8 +167,25 @@ struct Index {
this.signNum=val.body[1]
}
}else if(val.id=='48'){
console.log('valvalkkkk',val.body)
// if(val.body[13]=='1'){
// this.faceCompareSucess=1
// console.log('ttt111')
// // clearInterval(this.interval)
// this.facePass()
// }
}else if(val.id=='42'){
console.log('qkfnqkfn',val.body[0])
this.qkFn()
// this.getExaminationStudentInfoFn()
// const arr = [globalThis.signNum,1];
// let tmpList = [];
// tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
// tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
//
// const param= {id: 41,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
//
// globalThis.udpClient2.sendMsg(param, this.context)
}
})
// 应用启动时打开读卡设备
@ -168,6 +196,19 @@ struct Index {
} else {
console.error("zzctest Failed to Open Device");
}
// this.vocObj = new voiceService(async (status,val) => {
// if (status == 'idle') {
// if(val==='ksks.WAV'){
// router.pushUrl({
// url: 'pages/Judge',
// params:{examItems:this.examItems}
// }, router.RouterMode.Single);
// globalThis.statue=4
// this.vocObj&&this.vocObj.releasePlayer()
// }
// }
// });
if(globalThis.singlePlay){
this.list=[
{
@ -400,7 +441,7 @@ struct Index {
}
getqkFn(){
let tmpList = [];
tmpList.push(string2Bytes(globalThis.signNum, 1 * 8)[0])
tmpList.push(this.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)
@ -409,7 +450,7 @@ struct Index {
let tmpList=[]
const str =globalThis.lsh
for (let i = 0;i < str.length; i++) {
tmpList.push(string2Bytes(str.charCodeAt(i), 1 * 8)[0])
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:()=>{
@ -418,17 +459,42 @@ struct Index {
}}
this.interval=setInterval(()=>{
if(this.callBackFlag){
console.log('validqqq333')
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}
}
aboutToDisappear() {
clearInterval(this.interval)
clearInterval(this.interval2)
testNapi.StopReadCard();
// console.log("zzctest Close Device ret = " + testNapi.CloseDevice());
}
changeStudentStatue(val){
const arr = [globalThis.signNum||0, val]
let tmpList = [];
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
const str = globalThis.lsh
for (let i = 0;i < str.length; i++) {
tmpList.push(this.string2Bytes(str.charCodeAt(i), 1 * 8)[0])
}
// const str ='1111160366580'
// 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:()=>{
// const param = { id: 46, list: tmpList, carNo: 489, placeId: 62 }
const param= {id: 31,list:tmpList,carNo:globalThis.carInfo.carNo,placeId:globalThis.carInfo.examinationRoomId}
globalThis.udpClient2&&globalThis.udpClient2.sendMsg(param, this.context)
}
facePass(){
if(!this.stepFlag){
@ -521,7 +587,21 @@ struct Index {
})
})
}
// async getVideoConfig(){
// const data = await this.fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/logs/config/config3.txt');
// this.param=JSON.parse(data)
// }
changefaceCompareSucess() {
// globalThis.statue=3
console.log('this.faceCompareSuces',this.faceCompareSucess,JSON.stringify(this.currentUser))
// if(this.faceCompareSucess!=1){
// this.heartMsg(this.context)
// return
// }else{
// console.log('kkkk2')
// this.sfbdinterfaceFn()
//
// }
if(this.faceCompareSucess>0){
this.sfbdinterfaceFn()
}
@ -552,8 +632,12 @@ struct Index {
this.lsh=this.currentUser.lsh
globalThis.lsh=this.currentUser.lsh
globalThis.ksyh=this.currentUser.ksy1sfzmhm||this.currentUser.ksy2sfzmhm
// this.currentUser.kszp=this.photo+res.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
if(globalThis.singlePlay){
testNapi.StopReadCard();
// globalThis.statue=4
router.pushUrl({
url: 'pages/Judge',
},router.RouterMode.Single);
@ -667,11 +751,59 @@ struct Index {
this.lsh=this.currentUser.lsh
globalThis.lsh=this.lsh
globalThis.ksyh=this.currentUser.ksy1sfzmhm||this.currentUser.ksy2sfzmhm
// this.currentUser.kszp=this.photo+this.currentUser.kszp
// this.currentUser.ksmjzp=this.photo+this.currentUser.ksmjzp
// this.currentUser.kszp='data:image/jpg;base64,'+this.currentUser.kszp
// this.currentUser.ksmjzp='data:image/jpg;base64,'+this.currentUser.ksmjzp
// this.getPhotosForOtherFn(this.currentUser,1)
// this.getPhotosForOtherFn(this.currentUser,2)
// for (let i in this.currentUser) {
// this.currentUser[i] = decodeURI(this.currentUser[i])
// }
console.log('this.currentUse3' + JSON.stringify(this.currentUser))
this.pageIndex = 0
}).catch((error) => {
console.log('error12error' + error)
})
}
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;
}
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;
}
getPhotosForOtherFn(data,type){
const date=new Date()
const param={
@ -703,9 +835,15 @@ struct Index {
examinationStuAbsent(param).then(res => {
const arr = [this.signNum||0,1]
let tmpList = [];
tmpList.push(string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(string2Bytes(arr[1], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[0], 1 * 8)[0])
tmpList.push(this.string2Bytes(arr[1], 1 * 8)[0])
// const str ='1111160366580'
// 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: 489, placeId: 62 }
console.log('globalThis.signNum',globalThis.signNum)
const param= {id: 43,list:tmpList,carNo: globalThis.carInfo.carNo,placeId: globalThis.carInfo.examinationRoomId}
globalThis.udpClient2.sendMsg(param, this.context)
@ -735,6 +873,7 @@ struct Index {
yycs: ''
}
this.getExaminationStudentInfoFn()
// this.errorMsg = decodeURI(res.examinationStuAbsentRsp.head.resultMessage)
return
}
@ -1018,14 +1157,27 @@ struct Index {
.margin({ left: 53 * this.ratio })
Column() {
// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
// Image($r('app.media.yydj')).width(45 * this.ratio).height(45 * this.ratio)
// Text('语音对讲').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio)
// }
Image($r('app.media.yydj_btn'))
.width(220 * this.ratio)
.height(69 * this.ratio)
.backgroundImage($r('app.media.button_nor'))
.backgroundImageSize({ width: '100%', height: '100%' })
.margin({ bottom: 12 * this.ratio }).onClick(()=>{
// this.getCurrentStudent('3423231995014700007')
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
})
// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
// Image($r('app.media.gx')).width(45 * this.ratio).height(45 * this.ratio)
// Text(' 更 新 ').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio)
// }
Image($r('app.media.gx_btn'))
.width(220 * this.ratio)
.height(69 * this.ratio)
@ -1035,8 +1187,16 @@ struct Index {
this.faceCompareSucess=0
this.numCount=0
this.getExaminationStudentInfoFn()
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
})
// Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
// Image($r('app.media.qk')).width(45 * this.ratio).height(45 * this.ratio)
// Text(' 缺 考 ').fontSize(24 * this.ratio).fontColor('#fff').width(100 * this.ratio)
// }
Image($r('app.media.qk_btn'))
.width(220 * this.ratio)
.height(69 * this.ratio)