diff --git a/entry/src/main/ets/config/global.ts b/entry/src/main/ets/config/global.ets similarity index 100% rename from entry/src/main/ets/config/global.ts rename to entry/src/main/ets/config/global.ets diff --git a/entry/src/main/ets/config/index.ts b/entry/src/main/ets/config/index.ts deleted file mode 100644 index 06134974..00000000 --- a/entry/src/main/ets/config/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * @Author: wangzhongjie - * @Date: 2024-03-07 10:54:19 - * @LastEditors: wangzhongjie - * @LastEditTime: 2024-03-07 11:15:11 - * @Description: - * @Email: shutdown0630@163.com - */ -export * from "./global" -export * from "./judge" \ No newline at end of file diff --git a/entry/src/main/ets/config/judge.ts b/entry/src/main/ets/config/judge.ets similarity index 85% rename from entry/src/main/ets/config/judge.ts rename to entry/src/main/ets/config/judge.ets index 11b61d56..d1760555 100644 --- a/entry/src/main/ets/config/judge.ts +++ b/entry/src/main/ets/config/judge.ets @@ -7,6 +7,4 @@ * @Email: shutdown0630@163.com */ -export const JudgeConfig={ - -} + diff --git a/entry/src/main/ets/model/Other.ets b/entry/src/main/ets/model/Other.ets new file mode 100644 index 00000000..fe581357 --- /dev/null +++ b/entry/src/main/ets/model/Other.ets @@ -0,0 +1,4 @@ +export interface TakePhotoCallbackData { + fileSize: number; + errorCode: number +} \ No newline at end of file diff --git a/entry/src/main/ets/model/index.ets b/entry/src/main/ets/model/index.ets index 7ffc0fe8..3ba8ee0e 100644 --- a/entry/src/main/ets/model/index.ets +++ b/entry/src/main/ets/model/index.ets @@ -17,3 +17,5 @@ export * from "./CarCheck" export * from "./api" export * from "./TableColumn" + +export * from "./Other" diff --git a/entry/src/main/ets/pages/Settings.ets b/entry/src/main/ets/pages/Settings.ets index 720ff89e..1910e3be 100644 --- a/entry/src/main/ets/pages/Settings.ets +++ b/entry/src/main/ets/pages/Settings.ets @@ -1,6 +1,6 @@ import router from '@ohos.router' import { CarCheckDataType } from '../model/CarCheck' -import { BaseInfoType } from '../model/Common' +import { BaseInfoType, CarInfoType } from '../model/Common' import TopLogo from './compontents/TopLogo' @Entry @@ -9,7 +9,7 @@ struct Index { @State ratio: number = 1280 / 960 @State url: string = '' @State baseInfo: BaseInfoType = {} - @State carInfo: CarCheckDataType = {} + @State carInfo: CarInfoType = {} @State @Watch('outClick') outFlag: boolean = false; build() { @@ -88,8 +88,8 @@ struct Index { aboutToAppear() { // this.vocObj = new voiceService(async (status, val, next) => { // }); - this.carInfo = AppStorage.get('carInfo') - this.baseInfo = AppStorage.get('baseinfo') as BaseInfoType + this.carInfo = AppStorage.get('carInfo') + this.baseInfo = AppStorage.get('baseInfo') } outClick() { diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 76e6aee9..08c9ecf6 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -1404,15 +1404,3 @@ struct LabelBlock { } } -interface systemParam { - 'Param341': boolean, //是否按顺序考试 - 'Param803Str': string, //开始考试前必须解开安全带或关车门 - 'Param612Str': string, //开始考试触发方式 - 'Param305Str': string, //视频保存天数 - 'Param352Str': string, //车上考试过一次就不能缺考 - 'Param828Str': string, //828考生待考界面,安全员显示考试员 - 'Param770Str': string, //车上没有缺考功能 - 'Param830Str': string, //同一学员连续第二次考试时不再验证身份 - 'Param364': string, //考前上车准备 - 'Param398': string, //考前上车准备 -} \ No newline at end of file diff --git a/entry/src/main/ets/pages/judgeSDK/judge.ets b/entry/src/main/ets/pages/judgeSDK/judge.ets index 23b58d14..be7809a3 100644 --- a/entry/src/main/ets/pages/judgeSDK/judge.ets +++ b/entry/src/main/ets/pages/judgeSDK/judge.ets @@ -53,6 +53,7 @@ import { } from './api/index'; import { writeObjectOut } from '../../api/judge'; import { saveStartRecordVideo } from '../../utils/Video'; +import common from '@ohos.app.ability.common'; const judgeTag = 'SURENJUN_JUDGE' diff --git a/entry/src/main/ets/utils/Video.ets b/entry/src/main/ets/utils/Video.ets index ae7cd26c..e1062fff 100644 --- a/entry/src/main/ets/utils/Video.ets +++ b/entry/src/main/ets/utils/Video.ets @@ -1,16 +1,15 @@ -import mediaLibrary from '@ohos.multimedia.mediaLibrary' import photoAccessHelper from '@ohos.file.photoAccessHelper' import dataSharePredicates from '@ohos.data.dataSharePredicates' -import { dateFormat, getCurrentTime, isSevenDaysAgo } from '../utils/tools' -// import rtsp_server from '@ohos.rtsprecord'; import record from '@ohos.rtsprecord'; -import { FileHelper } from './FileHelper'; -import FileUtil from '../utils/File'; -import { GlobalConfig } from '../../config'; import promptAction from '@ohos.promptAction'; import { GetCurrentTime, IsDaysAgo } from './Common'; -import { RecordHandleType, VideoConfig } from '../model'; +import { RecordHandleType, TakePhotoCallbackData, VideoConfig } from '../model'; import common from '@ohos.app.ability.common'; +import { FileHelper } from '../common/service/FileHelper'; +import FileUtil from '../common/utils/File'; +import dayTs from './Date'; +import { GlobalConfig } from '../config'; +import { BusinessError } from '@ohos.base'; const rtsp_server = record.createServer(); //开始录屏 @@ -84,29 +83,37 @@ export async function endRecordVideo(record_handleObj: RecordHandleType) { } -export async function saveStartRecordVideo(path) { - return new Promise(async (reslove, reject) => { - const fileUtil = new FileUtil(globalThis.context) +export async function saveStartRecordVideo(path: string, context?: common.UIAbilityContext): Promise { + context = context || globalThis.context + return new Promise(async (resolve, reject) => { + const fileUtil = new FileUtil(context) const fileHelper = new FileHelper(); - const date = dateFormat(new Date).split(' ')[0] + // const date = dateFormat(new Date).split(' ')[0] + const date = dayTs().format('YYYY-MM-DD HH:mm:ss').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 + // TODO:待修改 + const data: string = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt'); + const param: VideoConfig = JSON.parse(data) + const record_handle: RecordHandleType = { + rocord_handle1: 0, + rocord_handle2: 1, + rocord_handle3: 2, + rocord_handle4: 3 } for (let i = 1; i <= 4; i++) { - if (param['videoRecord'+i]) { - console.log('pathpath0', path) + // if (param['videoRecord'+i]) { + // + // record_handle[i] = await getFilehandleCode(i, param, date, path, i) + // } + if (Reflect.get(param, 'videoRecord' + i)) { + // Reflect.set(record_handle, i, await getFileHandleCode(i, param, date, path, i)); + const data = await startRecordVideo(param, i, context, date, path, i); + Reflect.set(record_handle, i, data); - record_handle[i] = await getfilehandleCode(i, param, date, path, i) } } - reslove(record_handle) + resolve(record_handle) }) } @@ -135,7 +142,7 @@ interface takePhotoParam { */ const fileHelper = new FileHelper(); -export async function delPic(day, type) { +export async function delPic(day: number, type: number) { let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(globalThis.context); console.info('albumGetAssetsDemoCallback'); let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); @@ -162,82 +169,79 @@ export async function delPic(day, type) { } } -export async function takePhoto(param, context, dir, flag = 1, callback?) { +export async function takePhoto(param: VideoConfig, context: common.UIAbilityContext, dir: string, flag = 1, + callback?: (data: TakePhotoCallbackData) => void) { let video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`; const num = Math.floor(Math.random() * 10000) const fileName = `picture_record${num}.jpg` if (flag == 0) { - rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err, snapResult) => { + rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err: BusinessError, snapResult: record.RtspResult) => { callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode }) }); } else { return new Promise(async (resolve, reject) => { - const time = await getCurrentTime() + const time = await GetCurrentTime() const date = time.split(' ')[0] let dirName = dir ? dir : date - rtsp_server.getVideoSnapshot(context, video_uri, fileName, dirName, true, async (err, snapResult) => { - if (snapResult.result && snapResult.errorCode == 0) { - resolve({ - base64: snapResult.dataString, - name: snapResult.fileName, - fileSize: snapResult.fileSize, - errorCode: snapResult.errorCode - }) - } else { - promptAction.showToast({ - message: `拍照失败`, - duration: 3000 - }); - reject(false) - // reject() - } + rtsp_server.getVideoSnapshot(context, video_uri, fileName, dirName, true, + async (err: BusinessError, snapResult: record.RtspResult) => { + if (snapResult.result && snapResult.errorCode == 0) { + resolve({ + base64: snapResult.dataString, + name: snapResult.fileName, + fileSize: snapResult.fileSize, + errorCode: snapResult.errorCode + }) + } else { + promptAction.showToast({ + message: `拍照失败`, + duration: 3000 + }); + reject(false) + // reject() + } - }); + }); }) } } //type:1 是图片 2是视频 -export async function deleteAllFileByPiC(dirName, type = 1) { +export async function deleteAllFileByPiC(dirName: string, type = 1) { // const fileHelper = new FileHelper(); fileHelper.deleteFileOfAlbum(dirName, type); } -export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, +export async function deleteAllVideos(context: common.UIAbilityContext, type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise { let fetchResult: photoAccessHelper.FetchResult = null; try { const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context); fetchResult = await userFileMgr.getAlbums(type, subType); - console.log('baoyihu get Album fetchResult, count: ' + fetchResult.getCount()); for (let i = 0; i < fetchResult.getCount(); i++) { let albumAsset: photoAccessHelper.Album = await fetchResult.getObjectByPosition(i); let photoFetchResult: photoAccessHelper.FetchResult = null; let count = 0; try { let predicates = new dataSharePredicates.DataSharePredicates(); - let fetchOptions = { + let fetchOptions: photoAccessHelper.FetchOptions = { fetchColumns: FILE_ASSET_FETCH_COLUMNS, predicates: predicates }; photoFetchResult = await albumAsset.getAssets(fetchOptions); count = photoFetchResult.getCount(); - console.log('baoyihu photoFetchResult count: ' + count); - var all_fileAsset = await photoFetchResult.getAllObjects(); - var uri_array = [] - console.log('baoyihu batch delete begin'); + let all_fileAsset = await photoFetchResult.getAllObjects(); + let uri_array: string[] = [] for (let onfile of all_fileAsset) { console.log('baoyihu push one uri : ' + onfile.uri); uri_array.push(onfile.uri); } await userFileMgr.deleteAssets(uri_array); - console.log('baoyihu batch delete end'); } catch (err) { - console.log('baoyihu get Album getPhotoAssets failed with err: ' + err); } finally { if (photoFetchResult != null) { photoFetchResult.close();