From f35cf5fd22900a87ffbb66f8f3bf3875cb1cf940 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Thu, 2 Jan 2025 19:09:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?tcp=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/TcpClient.ts | 5 +++-- entry/src/main/ets/entryability/EntryAbility.ts | 2 +- .../ets/pages/compontents/judge/DeductionPopup.ets | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 5faa7762..6cff27e4 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -150,11 +150,12 @@ export default class TcpClient { promise.then(() => { reslove(true) }).catch(err => { - - if(!globalThis.getCloseTcp){ + globalThis.tcpSendNum++ + if(!globalThis.getCloseTcp&&globalThis.tcpSendNum>5){ setTimeout(async () => { getTCP(true) }, 3000) + globalThis.tcpSendNum=0 return } globalThis.getCloseTcp=true diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index 61797483..76776797 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -34,7 +34,7 @@ export default class EntryAbility extends UIAbility { // globalThis.version ='2023.12.13.01'; globalThis.version = GlobalConfig.version.jn.km3[0]; globalThis.judgeVersion = GlobalConfig.version.jn.km3[1]; - + globalThis.tcpSendNum=0 globalThis.videoVersion= '1.0' //视频遮挡 diff --git a/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets b/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets index 65a5a8bb..1dd6be67 100644 --- a/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets +++ b/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets @@ -46,15 +46,15 @@ export default struct DeductedPopup { } changeCurrentItems(){ - console.info('popup',JSON.stringify(this.currentItems)); - //@ts-ignore - this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno) || this.currentItems.includes(item.itemno + ''))); - this.currentIndex = this.defaultTabIndex - if(this.currentIndex == 1){ - this.universalMarkRules = this.markRules.filter(item => item.itemno == 20 ) + if(this.currentItems){ + //@ts-ignore + this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno) || this.currentItems.includes(item.itemno + ''))); + this.currentIndex = this.defaultTabIndex + if(this.currentIndex == 1){ + this.universalMarkRules = this.markRules.filter(item => item.itemno == 20 ) + } } } - //上一页 下一页 goPage(typeIndex){ const currentIndex = this.currentIndex From bf0e77bf1f530eb6f2809ea9da15e10ce2c70e86 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 3 Jan 2025 10:25:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?tcp=20send=E9=87=8D=E8=BF=9E=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/service/videoService.ts | 13 +++++++------ entry/src/main/ets/common/utils/TcpClient.ts | 7 ++++--- entry/src/main/ets/pages/Index.ets | 13 ++++++++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index 6bfd3976..38e20ba2 100644 --- a/entry/src/main/ets/common/service/videoService.ts +++ b/entry/src/main/ets/common/service/videoService.ts @@ -203,7 +203,6 @@ export async function delPic(day,type) { return } - 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`; // var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`; @@ -225,9 +224,9 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) { return new Promise(async (resolve, reject) => { const time = await getCurrentTime() const date = time.split(' ')[0] - await fileHelper.createAlbum(date) - rtsp_server.getVideoSnapshot(context, video_uri, fileName, '/jt', true,async (err, snapResult) => { - console.log('baoyihubaoyihu', video_uri, flag, JSON.stringify(snapResult.fileSize)) + let dirName=dir?dir:date + rtsp_server.getVideoSnapshot(context, video_uri, fileName,dirName, true,async (err, snapResult) => { + console.log('baoyihubaoyihu', video_uri, flag,fileName,dir, JSON.stringify(snapResult.fileSize)) console.log('getPhtot', JSON.stringify(snapResult)) if(snapResult.result&&snapResult.errorCode==0){ resolve({ @@ -248,8 +247,10 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) { }); }) } - console.log('getmyLog03') - +} +export async function deleteAllPicturesFn(){ + fileHelper.deleteAllPictures(); + deleteAllVideos(globalThis.context,photoAccessHelper.AlbumType.USER,photoAccessHelper.AlbumSubtype.VIDEO) } diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index 6cff27e4..c79d6163 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -13,6 +13,7 @@ export default class TcpClient { private oppositeIp: string = '' private oppositeIpPort: string = '' private num: number = 0//重连次数 + private tcpSendNum: number = 0//重连次数 private folderPath private tcp: any = null @@ -150,12 +151,12 @@ export default class TcpClient { promise.then(() => { reslove(true) }).catch(err => { - globalThis.tcpSendNum++ - if(!globalThis.getCloseTcp&&globalThis.tcpSendNum>5){ + this.tcpSendNum++ + if(!globalThis.getCloseTcp&&this.tcpSendNum>10){ setTimeout(async () => { getTCP(true) }, 3000) - globalThis.tcpSendNum=0 + this.tcpSendNum=0 return } globalThis.getCloseTcp=true diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index e57903ff..83cbf5ad 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -2,7 +2,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 { getCurrentTime, string2Bytes } from '../common/utils/tools'; import { FileHelper } from '../common/service/FileHelper'; import { getEsCarModel, } from '../common/service/initable'; import FileUtil from '../common/utils/File'; @@ -20,7 +20,9 @@ import { getSyncData } from '../common/service/initable'; import GetDistance from '../common/utils/GetDistance' import UdpEvent from '../common/utils/UdpEvent' import UIAbility from '@ohos.app.ability.UIAbility'; -import { endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; +import { + deleteAllPicturesFn, + endRecordVideo, getUserAlbumItemByDisplayName, saveStartRecordVideo } from '../common/service/videoService'; import imageBtn from './compontents/imageBtn' import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; @@ -85,6 +87,7 @@ struct Index { // type: 1, // name: 'button_media.wav' // }) + // deleteAllPicturesFn() if (this.loading) { return } @@ -334,6 +337,7 @@ struct Index { } async aboutToAppear() { + console.log('diyidiy') this.avPlayer = new VoiceAnnounce(); this.initParamFlag=false @@ -467,7 +471,6 @@ struct Index { } this.isSingle = globalThis.singlePlay // this.loading = false - this.createAlbum() this.num = 0 // const TcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) globalThis.lsh = '1111111111111' @@ -475,8 +478,11 @@ struct Index { async createAlbum() { this.fileHelper = new FileHelper(); + const time = await getCurrentTime() + const date = time.split(' ')[0] this.fileHelper.createAlbum('jt') this.fileHelper.createAlbum('pz'); + this.fileHelper.createAlbum(date); } @@ -545,6 +551,7 @@ struct Index { this.heartMsg() } }, 1000) + this.createAlbum() //下载模型 // await this.getModel() // const arr = [0x55, 0xaa, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00]