Compare commits

...

8 Commits

Author SHA1 Message Date
8e276824e8 圖片刪除 2024-08-29 11:04:10 +08:00
997cd3dc88 Merge branch 'dev' of http://88.22.24.105:3000/harmony_car/subject-two into dev 2024-08-29 08:10:37 +08:00
157a3e86f9 定期清理日志 2024-08-29 08:10:20 +08:00
c3eecd2b1a feat:评判修改 2024-08-27 19:51:58 +08:00
7c42a590a6 大網照片 2024-08-27 19:41:15 +08:00
555aa845fd 兼容處理 2024-08-27 12:42:06 +08:00
c76615d4de 補齊字段 2024-08-27 11:31:17 +08:00
708dd377af 1 2024-08-27 10:49:43 +08:00
9 changed files with 281 additions and 103 deletions

View File

@ -25,8 +25,8 @@ CommonConstants {
*/ */
static readonly ACCOUNT_TABLE = { static readonly ACCOUNT_TABLE = {
tableName: 'USERLIST', tableName: 'USERLIST',
sqlCreate: 'CREATE TABLE IF NOT EXISTS USERLIST(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT,ksmjzp TEXT,ksy2 TEXT,xldm TEXT,ksy2sfzmhm TEXT)', sqlCreate: 'CREATE TABLE IF NOT EXISTS USERLIST(id TEXT,sfzmhm TEXT,xm CHAR(20), lsh TEXT, kszp TEXT,ksdd TEXT,kssycs TEXT,kslx TEXT,kscx TEXT,ksxl TEXT,ksy1 TEXT,ksmjzp TEXT,ksy2 TEXT,xldm TEXT,ksy2sfzmhm TEXT,bz1 TEXT,kchp TEXT,xb TEXT,xh TEXT,yycs TEXT,jxmc TEXT,ksy1sfzmhm TEXT,kszt TEXT)',
columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1','ksmjzp','ksy2','xldm','ksy2sfzmhm'] columns: ['id','sfzmhm','xm','lsh','kszp','ksdd','kssycs','kslx','kscx','ksxl','ksy1','ksmjzp','ksy2','xldm','ksy2sfzmhm','bz1','kchp','xb','xh','yycs','jxmc','ksy1sfzmhm','kszt']
}; };
/** /**

View File

@ -5,7 +5,7 @@ import { dateFormat } from '../utils/tools'
import FileUtil from '../../common/utils/File' import FileUtil from '../../common/utils/File'
import AccountTable from '../../common/database/tables/AccountTable' import AccountTable from '../../common/database/tables/AccountTable'
import MA_SYSSET from '../../common/constants/MA_SYSSET' import MA_SYSSET from '../../common/constants/MA_SYSSET'
import { takePhoto } from '../../common/service/videoService' import { takePhoto,deleteAllFileByPiC } from '../../common/service/videoService'
import { import {
delSyncTable, delSyncTable,
@ -46,6 +46,7 @@ export async function deleteAllFIleLog(path){
"recursion": false, "recursion": false,
"listNum": 0, "listNum": 0,
}; };
let filenames = fs.listFileSync(path, options); let filenames = fs.listFileSync(path, options);
console.info("listFile succeed",JSON.stringify(filenames)); console.info("listFile succeed",JSON.stringify(filenames));
for (let i = 0; i < filenames.length; i++) { for (let i = 0; i < filenames.length; i++) {
@ -64,14 +65,35 @@ export async function deleteAllFIleLog(path){
} }
} }
export async function delHilog(){
console.log('kkkkmmm1')
const fileUtil = new FileUtil(globalThis.context)
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/hilogTime.txt');
const folderPath = await fileUtil.initFolder(`/config`);
console.log('kkkkmmm2',data)
if(data === '' || data === undefined){
const date=dateFormat(new Date()).split(' ')[0]
console.log('mm'.date)
fileUtil.addFile(`${folderPath}/hilogTime.txt`, date)
}else{
console.log('kkkkmmm2',data)
console.log('datadata',data,isSevenDaysAgo(data))
if(isSevenDaysAgo(data)){
const date=dateFormat(new Date()).split(' ')[0]
fileUtil.addFile(`${folderPath}/hilogTime.txt`, date)
deleteAllFileByPiC('jt',1)
// fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num))
}
}
}
function isSevenDaysAgo(date) { function isSevenDaysAgo(date) {
const today = new Date(); // 当前日期 const today = new Date(); // 当前日期
const target = new Date(date); // 需要判断的日期 const target = new Date(date); // 需要判断的日期
console.info("listFile succeed1",JSON.stringify(target)); console.info("listFile succeed1",JSON.stringify(target));
const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异 const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异
const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数 const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数
console.info("listFile succeed2",JSON.stringify(diffDays)); console.info("listFile succeed2",(diffDays));
// 如果差异天数正好是7则原日期是当前日期的前七天 // 如果差异天数正好是7则原日期是当前日期的前七天
return diffDays > 7; return diffDays > 7;
} }

View File

@ -5,45 +5,55 @@ import fs from '@ohos.file.fs'
// @ts-ignore // @ts-ignore
import photoAccessHelper from '@ohos.file.photoAccessHelper' import photoAccessHelper from '@ohos.file.photoAccessHelper'
import dataSharePredicates from '@ohos.data.dataSharePredicates' import dataSharePredicates from '@ohos.data.dataSharePredicates'
import { getCurrentTime } from '../utils/tools' import { dateFormat, getCurrentTime, isSevenDaysAgo } from '../utils/tools'
// import rtsp_server from '@ohos.rtsprecord'; // import rtsp_server from '@ohos.rtsprecord';
import record from '@ohos.rtsprecord'; import record from '@ohos.rtsprecord';
import { FileHelper } from './FileHelper'; import { FileHelper } from './FileHelper';
import FileUtil from '../utils/File';
import { GlobalConfig } from '../../config';
const rtsp_server = record.createServer(); const rtsp_server = record.createServer();
//开始录屏 //开始录屏
const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI, const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI,
photoAccessHelper.PhotoKeys.PHOTO_TYPE, photoAccessHelper.PhotoKeys.PHOTO_TYPE,
photoAccessHelper.PhotoKeys.DISPLAY_NAME, photoAccessHelper.PhotoKeys.DISPLAY_NAME,
photoAccessHelper.PhotoKeys.SIZE, photoAccessHelper.PhotoKeys.SIZE,
photoAccessHelper.PhotoKeys.DATE_ADDED, photoAccessHelper.PhotoKeys.DATE_ADDED,
photoAccessHelper.PhotoKeys.DATE_MODIFIED, photoAccessHelper.PhotoKeys.DATE_MODIFIED,
photoAccessHelper.PhotoKeys.DURATION, photoAccessHelper.PhotoKeys.DURATION,
photoAccessHelper.PhotoKeys.WIDTH, photoAccessHelper.PhotoKeys.WIDTH,
photoAccessHelper.PhotoKeys.HEIGHT, photoAccessHelper.PhotoKeys.HEIGHT,
photoAccessHelper.PhotoKeys.DATE_TAKEN, photoAccessHelper.PhotoKeys.DATE_TAKEN,
photoAccessHelper.PhotoKeys.ORIENTATION, photoAccessHelper.PhotoKeys.ORIENTATION,
photoAccessHelper.PhotoKeys.FAVORITE, photoAccessHelper.PhotoKeys.FAVORITE,
photoAccessHelper.PhotoKeys.TITLE, photoAccessHelper.PhotoKeys.TITLE,
photoAccessHelper.PhotoKeys.POSITION, photoAccessHelper.PhotoKeys.POSITION,
photoAccessHelper.PhotoKeys.DATE_TRASHED, photoAccessHelper.PhotoKeys.DATE_TRASHED,
photoAccessHelper.PhotoKeys.HIDDEN]; photoAccessHelper.PhotoKeys.HIDDEN];
// const rtsp_server = record.createServer(); // const rtsp_server = record.createServer();
export async function startRecordVideo(param, td, context, dir) { export async function startRecordVideo(param, td, context, dir, path?) {
return new Promise((reslove, reject) => { return new Promise(async (reslove, reject) => {
// const fileUtil = new FileUtil(globalThis.context)
// const date=dateFormat(new Date).split(' ')[0]
// const folderPath = await fileUtil.initFolder(`/PLC/${date}/${dir}`);
var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`; var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`;
if (rtsp_server != null) { if (rtsp_server != null) {
console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri); console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri);
const num = Math.floor(Math.random() * 10000) const num = Math.floor(Math.random() * 10000)
const fileName = `movie_record${num}.mp4` let fileName
if (!path) {
fileName = `movie_record${num}.mp4`
} else {
fileName = `${path}.mp4`
}
// @ts-ignore // @ts-ignore
var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, dir); var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, dir);
const handleId = recordResult.dataInt; const handleId = recordResult.dataInt;
console.log(`Rtsprecord startRecordVideo begin,handleId`, handleId);
reslove(handleId) reslove(handleId)
console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt);
} }
else { else {
console.log(`Rtsprecord startRecordVideo rtsp_server isnull`); console.log(`Rtsprecord startRecordVideo rtsp_server isnull`);
@ -55,33 +65,106 @@ export async function startRecordVideo(param, td, context, dir) {
} }
//结束录屏 //结束录屏
export async function endRecordVideo(record_handle) { export async function endRecordVideo(record_handleObj) {
if (rtsp_server != null && record_handle > 0) { for (let key in record_handleObj) {
console.log(`Rtsprecord endRecordVideo begin`); if (rtsp_server != null && record_handleObj[key] > 0) {
// @ts-ignore console.log(`Rtsprecord endRecordVideo begin`);
var recordResult = rtsp_server.endRecordVideo(record_handle); // @ts-ignore
console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt + ` filename:` + recordResult.fileName); var recordResult = rtsp_server.endRecordVideo(record_handleObj[key]);
console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` + record_handleObj[key].fileName);
}
else {
console.log(`Rtsprecord endRecordVideo handleId isnull`);
}
} }
else {
console.log(`Rtsprecord endRecordVideo handleId isnull`);
}
// var result = onvifclient.endRecordVideo(record_handle);
// fs.closeSync(record_handle);
// file_asset.close(record_handle);
} }
export async function saveStartRecordVideo(path) {
return new Promise(async (reslove, reject) => {
const fileUtil = new FileUtil(globalThis.context)
const fileHelper = new FileHelper();
const date = dateFormat(new Date).split(' ')[0]
fileHelper.createAlbum(date);
// const folderPath = await fileUtil.initFolder(`/${path}/${date}`);
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
const param = JSON.parse(data)
const record_handle = {
1: 0,
2: 1,
3: 2,
4: 3
}
for (let i = 1; i <= 4; i++) {
if (param['videoRecord'+i]) {
console.log('pathpath0',path)
record_handle[i] = await getfilehandleCode(i, param, date, path)
}
}
reslove(record_handle)
})
}
async function getfilehandleCode(td, param, dir, path) {
return new Promise(async (reslove, reject) => {
console.log('pathpath1',path)
const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path)
// this.rocordHandleObj['rocord_handle'+td] = record_handle
reslove(record_handle)
})
}
export async function getUserAlbumItemByDisplayName(displayName: string): Promise<photoAccessHelper.Album> {
let fetchResult = null
let album: photoAccessHelper.Album = null
try {
console.log('getUserAlbumItemByDisplayName');
let predicates = new dataSharePredicates.DataSharePredicates();
predicates.equalTo(photoAccessHelper.AlbumKeys.ALBUM_NAME, displayName)
let fetchOptions = {
fetchColumns: [],
predicates: predicates
};
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(globalThis.context);
fetchResult = await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult));
if (fetchResult.getCount() > 0) {
const albums = await fetchResult.getLastObject();
if(isSevenDaysAgo(albums.albumName)){
deleteAllFileByPiC(albums.albumName,2)
}
console.log('get getUserAlbumItemByDisplayName album',)
}
} catch (err) {
console.log('get Album getUserAlbumItemByDisplayName fetchResult failed with err: ' + err);
} finally {
if (fetchResult != null) {
fetchResult.close();
}
}
return album;
}
/** /**
* *
* @param param * @param param
* @param context * @param context
* @param type=0base64 * @param type=0base64
*/ */
interface takePhotoParam { interface takePhotoParam {
name?:string, name?: string,
base64?:string, base64?: string,
fileSize?:number, fileSize?: number,
errorCode?:number errorCode?: number
} }
/** /**
* *
* @param param * @param param
@ -92,32 +175,38 @@ interface takePhotoParam {
* @returns * @returns
*/ */
const fileHelper = new FileHelper(); const fileHelper = new FileHelper();
export async function takePhoto(param, context,dir,flag=1,callback?) {
var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`; export async function takePhoto(param, context, dir, flag = 1, callback?) {
// var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`;
const num = Math.floor(Math.random() * 10000) var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
const fileName = `picture_record${num}.jpg` // var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`;
console.log('baoyihubaoyihu',video_uri,flag)
console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName` + fileName); const num = Math.floor(Math.random() * 10000)
// @ts-ignore const fileName = `picture_record${num}.jpg`
// var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir); console.log('baoyihubaoyihu', video_uri, flag)
if(flag==0){
rtsp_server.detectVideoSnapshotSize(video_uri,fileName,(err,snapResult)=>{ console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName` + fileName);
console.log("baohaowen_detectLoop round end size1:"+snapResult.fileSize); // @ts-ignore
callback({fileSize:snapResult.fileSize,errorCode:snapResult.errorCode }) // var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir);
if (flag == 0) {
rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err, snapResult) => {
console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize);
callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode })
}); });
} }
else{ else {
console.log('baoyihubaoyihu1',video_uri,flag) console.log('baoyihubaoyihu1', video_uri, flag)
return new Promise<takePhotoParam>((resolve,reject)=>{ return new Promise<takePhotoParam>((resolve, reject) => {
rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,true,(err,snapResult)=>{ rtsp_server.getVideoSnapshot(context, video_uri, fileName, dir, true, (err, snapResult) => {
console.log('baoyihubaoyihu',video_uri,flag,JSON.stringify(snapResult)) console.log('baoyihubaoyihu', video_uri, flag, JSON.stringify(snapResult))
console.log('getPhtot',JSON.stringify(snapResult)) console.log('getPhtot', JSON.stringify(snapResult))
resolve({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize,errorCode:snapResult.errorCode }) resolve({
base64: snapResult.dataString,
name: snapResult.fileName,
fileSize: snapResult.fileSize,
errorCode: snapResult.errorCode
})
}); });
}) })
console.log('getmyLog02') console.log('getmyLog02')
@ -127,13 +216,14 @@ console.log('baoyihubaoyihu',video_uri,flag)
} }
//type:1 是图片 2是视频 //type:1 是图片 2是视频
export async function deleteAllFileByPiC(dirName,type=1) { export async function deleteAllFileByPiC(dirName, type = 1) {
// const fileHelper = new FileHelper(); // const fileHelper = new FileHelper();
fileHelper.deleteFileOfAlbum(dirName,type); fileHelper.deleteFileOfAlbum(dirName, type);
} }
export async function deleteAllVideos(context,type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> { export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null; let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
try { try {
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context); const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);

View File

@ -38,6 +38,7 @@ export class voiceService {
switch (state) { switch (state) {
case 'idle': // 成功调用reset接口后触发该状态机上报 case 'idle': // 成功调用reset接口后触发该状态机上报
// callBack('idle'); // callBack('idle');
console.log('jiangsong AVPlayer idle')
if(this.type==3){ if(this.type==3){
if(this.mediaArray.length&&!this.endFlag){ if(this.mediaArray.length&&!this.endFlag){
this.mediaArray.splice(0,1) this.mediaArray.splice(0,1)
@ -92,11 +93,13 @@ export class voiceService {
// 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例 // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
avPlayerFdSrc(name) { avPlayerFdSrc(name) {
globalThis.context.resourceManager.getRawFd(name, (error, value) => { globalThis.context.resourceManager.getRawFd(name,async (error, value) => {
if (error != null) { if (error != null) {
console.log(`jiangsong callback getRawFd failed error code: ${error.code}, message: ${error.message}.`); console.log(`jiangsong callback getRawFd failed error code: ${error.code}, message: ${error.message}.`);
} else { } else {
console.log('jiangsongjiangsong',this.avPlayer)
if (this.avPlayer) { if (this.avPlayer) {
await this.avPlayer.reset()
this.avPlayer.fdSrc = value; this.avPlayer.fdSrc = value;
} }
@ -128,6 +131,7 @@ export class voiceService {
} }
playAudio(param) { playAudio(param) {
console.log('jiangsong')
this.endFlag=false this.endFlag=false
this.mediaArray = [] this.mediaArray = []
this.type = param.type this.type = param.type

View File

@ -73,10 +73,10 @@ export const getMessageHeartbeat = async (msg) => {
const tempData = await getPlcData(msg); const tempData = await getPlcData(msg);
const examType = examSubject == 2?2:3 const examType = examSubject == 2?2:3
const {sensor,gps} = tempData; const {sensor,gps} = tempData;
const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs} = sensor const {zfxd,yfxd,shtd,ygd,jgd,skd,dh1,dh2,lhq,jsc,ssc,fsc,lb,mkg,aqd,ygq,cs,fdjzs,dw} = sensor
const {jd,wd, hxj, fyj, hbg,sd} = gps const {jd,wd, hxj, fyj, hbg,sd} = gps
const translateSignals = getTranslateSignals( const translateSignals = getTranslateSignals(
[zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd, 0, 0, 0, 0, 0, 0, ygq, sensor.wd, 0] [zfxd, yfxd, shtd, ygd, jgd, skd, dh1, dh2, lhq, jsc, ssc, fsc, lb, mkg, aqd].concat(getDwStatusType(dw)).concat([0,0,ygq, sensor.wd, 0])
) )
const translateProject = getTranslateProject(); const translateProject = getTranslateProject();
//@ts-ignore //@ts-ignore
@ -92,7 +92,7 @@ export const getMessageHeartbeat = async (msg) => {
} }
const arr = [ const arr = [
//考生号 //考生号
asclshArr.map(lsh => string2Bytes(lsh, 8)[0]), asclshArr.map(lsh => string2Bytes(lsh, 8)[0]),
//考试员号 //考试员号
ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]), ascksyhArr.map(ksyh => string2Bytes(ksyh, 8)[0]),
@ -284,4 +284,17 @@ const getPlcData = async (plc: string) => {
} }
return tempData return tempData
}
const getDwStatusType = (dw)=> {
switch (dw){
case 0:return [0,0,0,0]
case 1: return [0,0,0,1]
case 2: return [0,0,1,0]
case 3: return [0,0,1,1]
case 4: return [0,1,0,0]
case 5: return [0,1,0,1]
case 9: return [1,0,0,1]
default :return [0,0,0,0]
}
} }

View File

@ -2,7 +2,18 @@
import systemTime from '@ohos.systemDateTime'; import systemTime from '@ohos.systemDateTime';
import { expect } from '@ohos/hypium'; import { expect } from '@ohos/hypium';
import FileUtil from './File'; import FileUtil from './File';
export function isSevenDaysAgo(date) {
const today = new Date(); // 当前日期
const target = new Date(date); // 需要判断的日期
console.info("listFile succeed1",JSON.stringify(target));
const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异
const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数
console.info("listFile succeed2",JSON.stringify(diffDays));
// 如果差异天数正好是7则原日期是当前日期的前七天
console.log('diffDays',diffDays)
return diffDays > 7;
}
export async function writeLog(path,param){ export async function writeLog(path,param){
return return
const fileUtil = new FileUtil(globalThis.context) const fileUtil = new FileUtil(globalThis.context)

View File

@ -11,7 +11,7 @@ import { getUDP, getUDP2 } from '../common/utils/GlobalUdp';
import { initJudgeUdp } from '../common/utils/UdpJudge'; import { initJudgeUdp } from '../common/utils/UdpJudge';
import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { judgeConfig } from './judgeSDK/utils/judgeConfig';
import { getTCP } from '../common/utils/GlobalTcp'; import { getTCP } from '../common/utils/GlobalTcp';
import { getliushuiNum, setliushuiNum, takePhotoFn, deleteAllFIleLog } from '../common/service/indexService'; import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService';
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
import worker, { MessageEvents } from '@ohos.worker'; import worker, { MessageEvents } from '@ohos.worker';
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction'
@ -19,6 +19,8 @@ import { voiceService } from '../common/service/voiceService';
import errorMsgDialog from './compontents/errorMsgDialog' import errorMsgDialog from './compontents/errorMsgDialog'
import { getSyncData } from '../common/service/initable'; import { getSyncData } from '../common/service/initable';
import GetDistance from '../common/utils/GetDistance' import GetDistance from '../common/utils/GetDistance'
import UIAbility from '@ohos.app.ability.UIAbility';
// import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements';
@Entry @Entry
@ -144,7 +146,7 @@ struct Index {
if (this.loading) { if (this.loading) {
return return
} }
if(judgeConfig.isTrajectoryOpen){ if (judgeConfig.isTrajectoryOpen) {
router.pushUrl({ router.pushUrl({
url: 'pages/UserInfo', url: 'pages/UserInfo',
}, router.RouterMode.Single) }, router.RouterMode.Single)
@ -368,16 +370,23 @@ struct Index {
async onPageShow() { async onPageShow() {
console.log('ttttt', 1111) console.log('ttttt', 1111)
this.userAuth(); this.userAuth();
let resourceManager = this.context.resourceManager;
this.vocObj = new voiceService(async (status, val, next) => { this.vocObj = new voiceService(async (status, val, next) => {
}); });
console.log('globalThis.singlePlay', globalThis.singlePlay) console.log('globalThis.singlePlay', globalThis.singlePlay)
if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) {
this.vocObj.playAudio({ this.context.resourceManager.getRawFileContent("welcome.wav").then(value => {
type: 1, this.vocObj.playAudio({
name: 'welcome.wav' type: 1,
}) name: 'welcome.wav'
})
// let rawFile = value;
}).catch(error => {
console.log("getRawFileContent promise error is " + error);
});
globalThis.singlePlay = false globalThis.singlePlay = false
} }
this.isSingle = globalThis.singlePlay this.isSingle = globalThis.singlePlay
@ -421,6 +430,8 @@ struct Index {
} }
async initParams() { async initParams() {
console.log('kkkkmmm')
delHilog()
// deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/') // deleteAllFIleLog(GlobalConfig.comoonfileWriteAddress + '/PLC/')
//设置plc udp 同步requesthost //设置plc udp 同步requesthost
await getUDP(this.context, false) await getUDP(this.context, false)
@ -447,16 +458,6 @@ struct Index {
if (this.num >= 3) { if (this.num >= 3) {
this.heartMsg() this.heartMsg()
} }
// const data=AppStorage.Get('errorMsg');
// console.log('1123',data,globalThis.type,globalThis.dialogOpen)
// if(data==1){
// if(globalThis.type=='3'&&!globalThis.dialogOpen){
// globalThis.dialogOpen=true
// this.errorDialog.open()
// }else if(globalThis.type=='1'){
// this.errorDialog.open()
// }
// }
}, 1000) }, 1000)
//下载模型 //下载模型
// await this.getModel() // await this.getModel()

View File

@ -121,6 +121,7 @@ struct UserInfo {
async onPageShow() { async onPageShow() {
this.updateTimeLimit = false this.updateTimeLimit = false
this.ksksLimit = false this.ksksLimit = false
this.currentUser=EmptyCandidateObject
console.log('响应头地址响应头地址') console.log('响应头地址响应头地址')
const mediaTest = new FilePhoto(this.context); const mediaTest = new FilePhoto(this.context);
this.filePhoto = new FilePhoto(this.context); this.filePhoto = new FilePhoto(this.context);
@ -140,14 +141,23 @@ struct UserInfo {
this.list = await getSyncData('USERLIST') this.list = await getSyncData('USERLIST')
// @ts-ignore // @ts-ignore
const data = await getSyncData('USER') const data = await getSyncData('USER')
console.log('useruser,',JSON.stringify(this.list))
console.log('useruser1,',JSON.stringify(data))
const user = data[0] const user = data[0]
if (user && Number(user.kssycs)) { if (user && Number(user.kssycs)) {
let flag=false
this.list.forEach(res => { this.list.forEach(res => {
if (res.sfzmhm == user.sfzmhm) { if (res.sfzmhm == user.sfzmhm) {
flag=true
res.kssycs = user.kssycs res.kssycs = user.kssycs
this.getCurrentStudent(res.sfzmhm) this.getCurrentStudent(res.sfzmhm)
} }
}) })
if(!flag){
this.currentUser=(this.list.length?this.list[0]:EmptyCandidateObject)
}
} }
else if (user && (user.kssycs == '0' || user.kssycs == '')) { else if (user && (user.kssycs == '0' || user.kssycs == '')) {
console.log('datadatadatadata') console.log('datadatadatadata')
@ -157,7 +167,10 @@ struct UserInfo {
this.pageIndex = 0 this.pageIndex = 0
this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4)
if (this.dataList.length) { if (this.dataList.length) {
this.currentUser = this.dataList[0] setTimeout(()=>{
this.currentUser = this.dataList[0]
globalThis.lsh=this.currentUser.lsh
},200)
} else { } else {
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
} }
@ -244,7 +257,10 @@ struct UserInfo {
if (!flag) { if (!flag) {
globalThis.lsh = '0000000000000' globalThis.lsh = '0000000000000'
await upDateTableByArray('USER', []) await upDateTableByArray('USER', [])
this.currentUser = this.list[0] setTimeout(()=>{
this.currentUser = this.list[0]
},200)
// promptAction.showToast({ // promptAction.showToast({
// message: '未匹配到对应下载学员', // message: '未匹配到对应下载学员',
// duration: 3000 // duration: 3000
@ -505,12 +521,19 @@ struct UserInfo {
listData.kszp = this.photo + listData.kszp listData.kszp = this.photo + listData.kszp
listData.ksmjzp = this.photo + listData.ksmjzp listData.ksmjzp = this.photo + listData.ksmjzp
}) })
console.log('this.listthis.list',)
await upDateTableByArray('USERLIST', this.list || []) await upDateTableByArray('USERLIST', this.list || [])
dataList = this.list.length > 4 ? this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) : this.list; dataList = this.list.length > 4 ? this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) : this.list;
this.dataList = dataList this.dataList = dataList
if (this.dataList.length) { if (this.dataList.length) {
this.currentUser = this.dataList[0] setTimeout(()=>{
this.currentUser = this.dataList[0]
globalThis.lsh=this.currentUser.lsh
},200)
// this.currentUser = this.dataList[0]
console.log('this.currentUser1',JSON.stringify(this.currentUser))
} else { } else {
this.currentUser = EmptyCandidateObject this.currentUser = EmptyCandidateObject
} }
@ -518,6 +541,8 @@ struct UserInfo {
this.lsh = this.currentUser.lsh this.lsh = this.currentUser.lsh
globalThis.lsh = this.lsh globalThis.lsh = this.lsh
globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm globalThis.ksyh = this.currentUser.ksy1sfzmhm || this.currentUser.ksy2sfzmhm
console.log('globalThis.ksyh',this.currentUser.ksy1sfzmhm)
console.log('this.currentUse3' + JSON.stringify(this.currentUser)) console.log('this.currentUse3' + JSON.stringify(this.currentUser))
this.pageIndex = 0 this.pageIndex = 0
getSyncData('USER').then(data => { getSyncData('USER').then(data => {
@ -620,7 +645,7 @@ struct UserInfo {
const {code,keystr,message} = await this.beginExam(); const {code,keystr,message} = await this.beginExam();
console.info('surenjun','开始考试接口调用结束') console.info('surenjun','开始考试接口调用结束')
//@ts-ignore TODO code转换 //@ts-ignore TODO code转换
if (code == '' && code == undefined) { if (code != 1) {
promptAction.showToast({ promptAction.showToast({
message, message,
duration: 4000 duration: 4000
@ -638,7 +663,7 @@ struct UserInfo {
sczb: Number(this.isBoardPrePareSetPopupOpen), sczb: Number(this.isBoardPrePareSetPopupOpen),
kfdm: this.sczbkf, kfdm: this.sczbkf,
//真实监管项目 //真实监管项目
kString: keystr || '' kString: decodeURIComponent( keystr || '')
} }
}, router.RouterMode.Single); }, router.RouterMode.Single);
this.updateTimeLimit = false this.updateTimeLimit = false
@ -832,11 +857,15 @@ struct UserInfo {
.backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg')) .backgroundImage(item.sfzmhm != this.currentUser.sfzmhm ? $r('app.media.userbox2') : $r('app.media.userboxbg'))
.backgroundImageSize({ width: '100%', height: '100%' }) .backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => { .onClick(() => {
this.currentUser=EmptyCandidateObject
globalThis.lsh = item.lsh; globalThis.lsh = item.lsh;
if (this.isExamStart && !globalThis.singlePlay) { if (this.isExamStart && !globalThis.singlePlay) {
return return
} }
this.currentUser = item setTimeout(()=>{
this.currentUser = item
},200)
console.log('this.current',JSON.stringify(this.currentUser.ksmjzp))
}) })
}) })
@ -858,7 +887,6 @@ struct UserInfo {
Row() { Row() {
Column() { Column() {
if (this.currentUser['kszp']) { if (this.currentUser['kszp']) {
Avatar({ Avatar({
ratio: this.ratio, ratio: this.ratio,
url: this.currentUser['kszp'] ? this.currentUser['kszp'] : '' url: this.currentUser['kszp'] ? this.currentUser['kszp'] : ''
@ -1063,6 +1091,7 @@ struct Avatar {
.margin({ bottom: 10 * this.ratio, right: 58 * this.ratio, left: 55 * this.ratio }) .margin({ bottom: 10 * this.ratio, right: 58 * this.ratio, left: 55 * this.ratio })
.backgroundColor('orange') .backgroundColor('orange')
.border({ color: '#fff', width: 1, style: BorderStyle.Solid }) .border({ color: '#fff', width: 1, style: BorderStyle.Solid })
.syncLoad(true)
} }
} }
} }
@ -1104,7 +1133,7 @@ struct LabelBlock {
Row() { Row() {
Text(this.label).fontSize(20 * this.ratio).fontColor('#99948A') Text(this.label).fontSize(20 * this.ratio).fontColor('#99948A')
Row() { Row() {
Text(decodeURIComponent(this.value)) Text(decodeURIComponent(this.value||'')|| '')
.fontColor('#fff') .fontColor('#fff')
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.width('100%') .width('100%')

View File

@ -815,19 +815,28 @@ export default class Judge {
this.isExamEnd = true this.isExamEnd = true
} }
this.isManual = true this.isManual = true
} else { } else {
const param302 = judgeConfigObj['302'];
const param342 = judgeConfigObj['342'];
const param512 = (judgeConfigObj['512'] || '').split(',');
//单机模式 //单机模式
if (singlePlay) { if (singlePlay) {
console.info(judgeTag + ' isAllProjectsEnd => ',isAllProjectsEnd) console.info(judgeTag + ' isAllProjectsEnd => ',isAllProjectsEnd)
if (isAllProjectsEnd) { if (isAllProjectsEnd) {
await examJudgeEndExam() if (examSubject == 3 && (param342 == 0 || param342 == 2) && (param302 != 6 || param302 != 7 || param302 != 8)) {
this.isExamEnd = true if(param512[7] != 0){
avPlayer.playAudio(['voice/综合评判.mp3'])
this.judgeUI.isDeductedPopShow = true
this.judgeUI.defaultTabIndex = 1
this.isEndTip = true
}
} else {
await examJudgeEndExam()
this.isExamEnd = true
}
} }
} else { } else {
const param302 = judgeConfigObj['302'];
const param342 = judgeConfigObj['342'];
const param512 = (judgeConfigObj['512'] || '').split(',');
//成绩不合格 //成绩不合格
if (totalScore < passingGrade) { if (totalScore < passingGrade) {
//科目三不合格报靠边停车 //科目三不合格报靠边停车
@ -841,7 +850,6 @@ export default class Judge {
} }
//成绩合格 //成绩合格
if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) { if (isAllProjectsEnd && totalScore >= passingGrade && !isEndTip) {
//考试合格自动退出 //考试合格自动退出
if(examSubject == 3 && param302 == 4){ if(examSubject == 3 && param302 == 4){
await examJudgeEndExam() await examJudgeEndExam()
@ -874,7 +882,7 @@ export default class Judge {
const {judgeUI,endExam,handleSEP,kfArr,avPlayer,judgeTask,isManual} = this; const {judgeUI,endExam,handleSEP,kfArr,avPlayer,judgeTask,isManual} = this;
const {judgeConfigObj,examSubject,isAllProjectsEnd,totalScore,passingScore} = judgeUI; const {judgeConfigObj,examSubject,isAllProjectsEnd,totalScore,passingScore} = judgeUI;
//计算考试分数 //计算考试分数
this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0; // this.judgeUI.totalScore = isAllProjectsEnd ? totalScore : 0;
const singlePlay = globalThis.singlePlay const singlePlay = globalThis.singlePlay
const param302 = judgeConfigObj['302']; const param302 = judgeConfigObj['302'];
// globalThis.windowClass.setWindowSystemBarEnable(['navigation']) // globalThis.windowClass.setWindowSystemBarEnable(['navigation'])