From 77ddbc9c1f4f9456b8defdb38bbf7b89662272e2 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 30 Aug 2024 12:30:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=8D=E7=85=A7=E9=8C=84=E5=83=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/common/service/videoService.ts | 12 +++++++----- entry/src/main/ets/common/utils/TcpClient.ts | 2 -- .../main/ets/common/utils/UdpClientByCenter.ts | 16 ++++++++-------- entry/src/main/ets/entryability/EntryAbility.ts | 4 ++-- entry/src/main/ets/pages/Index.ets | 9 ++++----- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index be4b22f7..eb3b2542 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -33,7 +33,7 @@ const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI, // const rtsp_server = record.createServer(); -export async function startRecordVideo(param, td, context, dir, path?) { +export async function startRecordVideo(param, td, context, dir, path?,index?) { return new Promise(async (reslove, reject) => { // const fileUtil = new FileUtil(globalThis.context) // const date=dateFormat(new Date).split(' ')[0] @@ -47,7 +47,7 @@ export async function startRecordVideo(param, td, context, dir, path?) { if (!path) { fileName = `movie_record${num}.mp4` } else { - fileName = `${path}.mp4` + fileName = `${path}_${index||num}.mp4` } // @ts-ignore @@ -101,18 +101,18 @@ export async function saveStartRecordVideo(path) { if (param['videoRecord'+i]) { console.log('pathpath0',path) - record_handle[i] = await getfilehandleCode(i, param, date, path) + record_handle[i] = await getfilehandleCode(i, param, date, path,i) } } reslove(record_handle) }) } -async function getfilehandleCode(td, param, dir, path) { +async function getfilehandleCode(td, param, dir, path,index) { return new Promise(async (reslove, reject) => { console.log('pathpath1',path) - const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path) + const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path,index) // this.rocordHandleObj['rocord_handle'+td] = record_handle reslove(record_handle) }) @@ -137,6 +137,8 @@ export async function getUserAlbumItemByDisplayName(displayName: string): Promis console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); if (fetchResult.getCount() > 0) { const albums = await fetchResult.getLastObject(); + console.log('get getUserAlbumItemByDisplayName album111',albums.albumName) + if(isSevenDaysAgo(albums.albumName)){ deleteAllFileByPiC(albums.albumName,2) } diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index f3380498..eea1e52d 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -195,7 +195,6 @@ export default class TcpClient { } clearInterval(globalThis.intervaltcp) globalThis.intervaltcp=setInterval(()=>{ - // setTimeout(async () => { //程序断开 if (globalThis.tcpUdpError) { console.log(TAG,'tcp信号丢失') @@ -206,7 +205,6 @@ export default class TcpClient { }); } globalThis.tcpUdpError = true; - // }, 2000) },3000) // callback(value.message) }); diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index bef8ac0d..87156197 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -343,10 +343,10 @@ export default class UdpClientByCenter { // this.stashFn(str) const newArr = JSON.parse(JSON.stringify(strachArr)) - // this.writeLog({ - // time:dateFormat(new Date()), - // PLC: JSON.stringify(newArr.toString()), - // }) + this.writeLog({ + time:dateFormat(new Date()), + PLC: JSON.stringify(newArr.toString()), + }) if(strachArr[83]!='4'){ this.chafenFlag++ if(this.chafenFlag>=15&&!globalThis.dialogOpen){ @@ -393,10 +393,10 @@ export default class UdpClientByCenter { this.testIfUdpConnetced(callback) } async writeLog(param){ - // const fileUtil = new FileUtil(globalThis.context) - // const date=dateFormat(new Date).split(' ')[0] - // const folderPath = await fileUtil.initFolder(`/PLC/${date}`); - // fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`) + const fileUtil = new FileUtil(globalThis.context) + const date=dateFormat(new Date).split(' ')[0] + const folderPath = await fileUtil.initFolder(`/PLC/${date}`); + fileUtil.editFile(`${folderPath}/plcLog.txt`, JSON.stringify(param)+`\n`) } //获取当前UDP信号 diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 643a1add..b587e5d0 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -59,8 +59,8 @@ export default class EntryAbility extends UIAbility { const windowClass = await windowStage.getMainWindow(); globalThis.windowClass = windowClass - // await windowClass.setWindowLayoutFullScreen(true) - await windowClass.setWindowSystemBarEnable([]) //全屏 + await windowClass.setWindowLayoutFullScreen(true) + // await windowClass.setWindowSystemBarEnable([]) //全屏 // await windowClass.setWindowSystemBarEnable(['navigation']) windowStage.loadContent('pages/Index', (err, data) => { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 14704146..43beacc4 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,4 +1,3 @@ -// @ts-nocheck import common from '@ohos.app.ability.common'; import router from '@ohos.router'; import { getCarInfo, getDeviceInfo } from '../common/service/terminalService'; @@ -12,7 +11,6 @@ import { initJudgeUdp } from '../common/utils/UdpJudge'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { getTCP } from '../common/utils/GlobalTcp'; import { getliushuiNum, setliushuiNum, takePhotoFn, delHilog } from '../common/service/indexService'; -import { getUserAlbumItemByDisplayName } from '../common/service/videoService'; import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl'; import worker, { MessageEvents } from '@ohos.worker'; import promptAction from '@ohos.promptAction' @@ -21,6 +19,7 @@ import errorMsgDialog from './compontents/errorMsgDialog' import { getSyncData } from '../common/service/initable'; import GetDistance from '../common/utils/GetDistance' import UIAbility from '@ohos.app.ability.UIAbility'; +import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; // import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; @@ -46,8 +45,6 @@ struct Index { private vocObj = null; private workerInstance = null; private context = getContext(this) as common.UIAbilityContext; - private title = '' - private type = '2' errorDialog: CustomDialogController = new CustomDialogController({ builder: errorMsgDialog({ title: globalThis.title, @@ -331,6 +328,7 @@ struct Index { workerInstance.postMessage(param); workerInstance.onmessage = (e: MessageEvents): void => { console.log("baoyihu after postMessage :", JSON.stringify(e.data)); + // @ts-ignore let workData: WorkData = e.data; if (workData.isComplete) { router.pushUrl({ @@ -379,6 +377,7 @@ struct Index { console.log('globalThis.singlePlay', globalThis.singlePlay) if (globalThis.singlePlay == undefined || globalThis.singlePlay == null) { this.context.resourceManager.getRawFileContent("welcome.wav").then(value => { + console.log('tttttttt') this.vocObj.playAudio({ type: 1, name: 'welcome.wav' @@ -460,7 +459,7 @@ struct Index { } }, 1000) delHilog() - // getUserAlbumItemByDisplayName() + getUserAlbumItemByDisplayName('') //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]