From 8e2b093a67c72908eddb8fa315db9f5fe6490ec5 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Fri, 20 Dec 2024 13:28:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/common/utils/GlobalTcp.ts | 14 ++++++++--- entry/src/main/ets/common/utils/TcpClient.ts | 13 +++++----- .../src/main/ets/entryability/EntryAbility.ts | 4 +-- entry/src/main/ets/pages/UserInfo.ets | 25 +++++++++++-------- .../ets/pages/compontents/SignDisplayCom.ets | 20 +++++++++++---- .../compontents/judge/DeductionPopup.ets | 16 ++++++------ .../ets/pages/judgeSDK/utils/judgeConfig.ts | 5 ++-- 7 files changed, 59 insertions(+), 38 deletions(-) diff --git a/entry/src/main/ets/common/utils/GlobalTcp.ts b/entry/src/main/ets/common/utils/GlobalTcp.ts index acc5a373..0c526557 100644 --- a/entry/src/main/ets/common/utils/GlobalTcp.ts +++ b/entry/src/main/ets/common/utils/GlobalTcp.ts @@ -17,9 +17,11 @@ export async function getTCP() { // const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) // globalThis.TcpClient = tcpClient setTimeout(async () => { - await globalThis.TcpClient.rebindTcp(result.tcplocalIp, result.tcplocalIpPort, result.tcpOppositeIp, result.tcpOppositePort) + const tcpClient: TcpClient = new TcpClient(result.tcplocalIp, result.tcplocalIpPort, result.tcpOppositeIp, result.tcpOppositePort) + globalThis.TcpClient = tcpClient + await globalThis.TcpClient.bindTcp() + // await globalThis.TcpClient.rebindTcp(result.tcplocalIp, result.tcplocalIpPort, result.tcpOppositeIp, result.tcpOppositePort) await globalThis.TcpClient.connectTcp() - await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 globalThis.TcpClient.onError((val) => { setTimeout(() => { getTCP() @@ -27,7 +29,6 @@ export async function getTCP() { }) await globalThis.TcpClient.onMessage((val) => { setTimeout(() => { - globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 if (val) { // const msg=val.substring(5,val.length-1) console.log('socketTag[PLC.UdpClient] status:', globalThis.udpClient.getStatus()) @@ -46,6 +47,12 @@ export async function getTCP() { await globalThis.TcpClient.bindTcp() await globalThis.TcpClient.connectTcp() await globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 + clearInterval(globalThis.intervalSendmsg) + globalThis.intervalSendmsg=setInterval(()=>{ + if(!globalThis.getCloseTcp){ + globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 + } + },1000/3) globalThis.TcpClient.onError((val) => { setTimeout(() => { getTCP() @@ -54,7 +61,6 @@ export async function getTCP() { await globalThis.TcpClient.onMessage((val) => { hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val)); setTimeout(() => { - globalThis.TcpClient.sendMsg(globalThis.carInfo.carNo) //1002 if (val && globalThis.udpClient?.sendMsg) { globalThis.udpClient?.sendMsg(val) } diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index cf20eeae..fc14314c 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -62,7 +62,7 @@ export default class TcpClient { time:dateFormat(new Date()), message: `${TAG} tcprebind tcpreBinderror${JSON.stringify(err)}`, }) - globalThis.getCloseTcp = true + // globalThis.getCloseTcp = true hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err)); resolve(true) } @@ -71,7 +71,7 @@ export default class TcpClient { message: `${TAG} tcprebind success`, }) console.log('testTag,rebindtestTag tcp bind success'); - globalThis.getCloseTcp = false + // globalThis.getCloseTcp = false resolve(false) }) @@ -105,12 +105,12 @@ export default class TcpClient { message: `${TAG} tcpbind error ${JSON.stringify(err)}`, }) console.log('testTag tcp bind faile'); - globalThis.getCloseTcp = true + // globalThis.getCloseTcp = true hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err)); resolve(true) return } - globalThis.getCloseTcp = false + // globalThis.getCloseTcp = false console.log('testTag tcp bind success'); // this.writeLog({ // time:dateFormat(new Date()), @@ -171,7 +171,6 @@ export default class TcpClient { } }); console.log('socketTag','success') - globalThis.getCloseTcp = false resolve(true) }).catch(err => { @@ -180,7 +179,7 @@ export default class TcpClient { time:dateFormat(new Date()), message: `${TAG} TCPconnect error2 ${JSON.stringify(err)}`, }) - globalThis.getCloseTcp = true + // globalThis.getCloseTcp = true this.num++ if(this.num>3){ return @@ -244,7 +243,7 @@ export default class TcpClient { //程序断开 if (globalThis.tcpUdpError) { console.log(TAG,'tcp信号丢失') - getTCP() + // getTCP() prompt.showToast({ message: 'tcp信号丢失', duration: 2000 diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index ef3db41a..cdd454b2 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -30,8 +30,8 @@ export default class EntryAbility extends UIAbility { globalThis.deviceNo = ''; globalThis.hasAuth = false - globalThis.version = GlobalConfig.version.sz.km2[0]; - globalThis.judgeVersion = GlobalConfig.version.sz.km2[1]; + globalThis.version = GlobalConfig.version.jn.km3[0]; + globalThis.judgeVersion = GlobalConfig.version.jn.km3[1]; globalThis.videoVersion= '1.0' diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index ae6b6240..5c972f6b 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -32,7 +32,8 @@ struct UserInfo { @State pageIndex: number = 0 @State ratio: number = 1700 / 960 @State index: number = 0 - @State stepFlag: boolean = false; + @State stepFlag: + boolean = false; @State errorMsg: string = '' @State ksxtbh: string = '' @State pic: string = '' @@ -180,8 +181,7 @@ struct UserInfo { if (this.dataList.length) { setTimeout(()=>{ this.currentUser = this.dataList[0] - this.currentUser.ksy2= globalThis.ksyxm - + this.currentUser.ksy2= globalThis.kgxm globalThis.lsh=this.currentUser.lsh },200) } else { @@ -253,7 +253,7 @@ struct UserInfo { if (res.sfzmhm == id) { flag = true this.currentUser = res - this.currentUser.ksy2= globalThis.ksyxm + this.currentUser.ksy2= globalThis.kgxm this.lsh = this.currentUser.lsh globalThis.lsh = this.currentUser.lsh @@ -284,7 +284,7 @@ struct UserInfo { await upDateTableByArray('USER', []) setTimeout(()=>{ this.currentUser = this.list[0] - this.currentUser.ksy2= globalThis.ksyxm + this.currentUser.ksy2= globalThis.kgxm globalThis.lsh = this.currentUser.lsh },200) @@ -370,7 +370,7 @@ struct UserInfo { this.pageIndex = 0 this.dataList = this.list.slice(this.pageIndex * 4, this.pageIndex * 4 + 4) this.currentUser = this.dataList[0] - this.currentUser.ksy2= globalThis.ksyxm + this.currentUser.ksy2= globalThis.kgxm this.lsh = this.currentUser.lsh globalThis.ksyh = this.currentUser.ksy1sfzmhm @@ -487,6 +487,7 @@ struct UserInfo { if(!Number(this.systemParam.Param305Str)){ that.systemParam.Param305Str='2' } + console.log('Param305Str',that.systemParam.Param305Str) // delHilog(this.Param305Str) getUserAlbumItemByDisplayName('', that.systemParam.Param305Str,1) getUserAlbumItemByDisplayName('',that.systemParam.Param305Str,2) @@ -602,9 +603,11 @@ struct UserInfo { listData[i] = decodeURI(listData[i]) } if(this.systemParam.Param828Str=='1'||this.systemParam.Param828Str=='2'){ - listData.ksy2=listData.ksy1; + // listData.ksy2=listData.ksy1; + listData.ksy2=globalThis.kgxm }else{ - listData.ksy2=listData.ksy2; + // listData.ksy2=listData.ksy2; + listData.ksy2=globalThis.kgxm } listData.kszp = this.photo + listData.kszp listData.ksmjzp = this.photo + listData.ksmjzp @@ -616,7 +619,7 @@ struct UserInfo { if (this.dataList.length) { setTimeout(()=>{ this.currentUser = this.dataList[0] - this.currentUser.ksy2= globalThis.ksyxm + this.currentUser.ksy2= globalThis.kgxm globalThis.lsh=this.currentUser.lsh },200) // this.currentUser = this.dataList[0] @@ -896,7 +899,7 @@ struct UserInfo { //接口标识 jkid: '17C51', } - console.info('surenjun', JSON.stringify(param)) + console.info('surenjunjianguan', JSON.stringify(param)) const temp = await writeObjectOut(param); globalThis.lsh = this.currentUser.lsh globalThis.ksyh = this.currentUser.ksy1sfzmhm @@ -1022,7 +1025,7 @@ struct UserInfo { globalThis.lsh = item.lsh; setTimeout(()=>{ this.currentUser = item - this.currentUser.ksy2= globalThis.ksyxm + this.currentUser.ksy2= globalThis.kgxm },200) diff --git a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets index 4e85bf27..69694d54 100644 --- a/entry/src/main/ets/pages/compontents/SignDisplayCom.ets +++ b/entry/src/main/ets/pages/compontents/SignDisplayCom.ets @@ -4,7 +4,8 @@ import FileLog from '../judgeSDK/utils/fileLog'; import RealTime from '../compontents/judge/RealTime'; import { GPSData, SignalData } from '../../mock'; import { SignalDataType } from '../../model'; - +import FileUtil from '../../common/utils/File' +import { GlobalConfig } from '../../config/index' @Component export default struct SignDisplayCom { @State showBack: boolean = false @@ -13,6 +14,7 @@ export default struct SignDisplayCom { @State signArr: Array = [] @State sjxhColum: Array = SignalData @State GPSColum: Array = GPSData + @State udplocalIp: string = '' @State ratio: number = 850 / 960 @State gpsActive: number = 1 @Prop active: number = 0 @@ -166,7 +168,7 @@ export default struct SignDisplayCom { }.justifyContent(FlexAlign.Start).padding({ left: 10 * this.ratio }).margin({ top: 8 * this.ratio }) Row() { - Text("本机IP:" + this.signArr[53] || '0') + Text("本机IP:" + '192.168.7.170') .fontColor('#FFF5E5') .fontSize(14 * this.ratio) .width('25%') @@ -219,7 +221,7 @@ export default struct SignDisplayCom { Text('时分秒:' + this.signArr[94]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) Text('经度:' + this.signArr[95]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) Text('纬度:' + this.signArr[96]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) - Text('速度:' + this.signArr[97]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) + Text('速度:' +((Number((this.signArr[97]||0))*1.852).toFixed(2)).toString()).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) } .backgroundColor('#1A1A1A') .width(170 * this.ratio) @@ -319,7 +321,10 @@ export default struct SignDisplayCom { clearInterval(this.interval) } - aboutToAppear() { + async aboutToAppear() { + // const fileUtil = new FileUtil(globalThis.context) + // const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt') + // this.udplocalIp=JSON.parse(data)?.udplocalIp||'192.168.7.170' this.ratio = this.ratio * (this.scaleNum || 1); const that = this const {showBack,getSignal} = this @@ -369,7 +374,6 @@ export default struct SignDisplayCom { } getSignal = (msg) => { - console.log('msgmsgmsg', msg) const that = this; that.msg = msg const strachArr = msg.split(',') @@ -411,6 +415,12 @@ export default struct SignDisplayCom { this.GPSColum[t].value = this.signArr[i] t++ } + this.GPSColum[14].value = ((Number((this.signArr[97]||0))*1.852).toFixed(2)).toString() + const str0=this.signArr[93].substr(0,2) + const str1=this.signArr[93].substr(2,2) + const str2=this.signArr[93].substr(4.2) + this.signArr[93]=str2+str1+str0 + // this.signArr[53]=192.168.7.170' this.sjxhColum = JSON.parse(JSON.stringify((this.sjxhColum))) that.signArr = JSON.parse(JSON.stringify((this.signArr))) that.GPSColum = JSON.parse(JSON.stringify((this.GPSColum))) diff --git a/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets b/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets index 8af10027..eac1b909 100644 --- a/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets +++ b/entry/src/main/ets/pages/compontents/judge/DeductionPopup.ets @@ -12,7 +12,7 @@ export default struct DeductedPopup { super() } - @State fontSize:number = 24 + @State fontSize:number = 30 @State unselected:SEL = {fontColor:'#000000', bgColor:'#CCC4B8'} @State selected:SEL = {fontColor:'#FFAD33', bgColor:'#26231E'} @@ -90,7 +90,7 @@ export default struct DeductedPopup { Row(){ Text(text).fontColor(index === this.currentIndex ? this.selected.fontColor : this.unselected.fontColor).fontSize(this.fontSize).fontWeight(500) } - .width(120).height(60) + .width(140).height(60) .backgroundColor(index === this.currentIndex ? this.selected.bgColor: this.unselected.bgColor ).justifyContent(FlexAlign.Center).justifyContent(FlexAlign.Center) .borderRadius({topLeft:20,topRight:20}).margin({right:10}) .onClick(()=>{ @@ -113,7 +113,7 @@ export default struct DeductedPopup { Row(){ Image($rawfile(`judge/km3/zuo_nor.png`)).height(15).margin({left:20,top:0}) Text('上一页'){}.fontColor('#FFF').fontSize(this.fontSize) - }.width(140).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}).margin({right:15}) + }.width(150).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}).margin({right:30}) .onClick(()=>{this.goPage(0)}) } @@ -123,7 +123,7 @@ export default struct DeductedPopup { Row(){ Text('下一页'){}.fontColor('#FFF').fontSize(this.fontSize).padding({left:30}) Image($rawfile(`judge/km3/you_nor.png`)).height(15).margin({right:6,top:0}) - }.width(140).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}).margin({right:15}) + }.width(150).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}).margin({right:30}) .onClick(()=>{this.goPage(1)}) } @@ -138,12 +138,14 @@ export default struct DeductedPopup { Column(){ ForEach(this.getCurrentMarkRuleList(),(item,index) => { Row(){ - Text(`${item.markshow} (${item.markcatalog})`).fontColor('#FFF').fontSize(this.fontSize).fontWeight(500) Row(){ - Text(item.markreal + '').fontColor('#FFF').fontSize(this.fontSize).fontWeight(500) + Text(`${item.markshow} (${item.markcatalog})`).fontColor('#FFF').fontSize(this.fontSize).fontWeight(600) + }.width(1000) + Row(){ + Text(item.markreal + '').fontColor('#FFF').fontSize(this.fontSize).fontWeight(600) } } - .width('100%').height(70).justifyContent(FlexAlign.SpaceBetween).alignItems(VerticalAlign.Center) + .width('100%').justifyContent(FlexAlign.SpaceBetween).alignItems(VerticalAlign.Center).constraintSize({minHeight:70}) .padding({left:20,right:20}) .backgroundColor(this.getSelectedLine(index)) .onClick(()=>{this.selectedLine = index}) diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts index a505696d..3d90118a 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts @@ -2,13 +2,14 @@ //考试回放开关 export const judgeConfig = { //本地目录开关 - isTrajectoryOpen: true, + isTrajectoryOpen: false, //是否开启拍照 - isPhotoOpen: false, + isPhotoOpen: true, //扣分语音是否强制开启 kfVoiceOpen: false, //忽略的考试项目 ignoreProjects:[], + // 是否忽略考试前熄火、车门检查 isCheckFireOpen: true, //轨迹回放是否开启Udp From c1363263b26688ca0b402f7829887d892a069ba6 Mon Sep 17 00:00:00 2001 From: lvyuankang <1344032923@qq.com> Date: Tue, 24 Dec 2024 16:43:59 +0800 Subject: [PATCH 2/2] 1 --- .../main/ets/common/service/indexService.ts | 3 + .../main/ets/common/service/videoService.ts | 74 +++++++++++++------ entry/src/main/ets/common/utils/File.ts | 23 +++--- .../src/main/ets/common/utils/GetDistance.ts | 1 + entry/src/main/ets/common/utils/GlobalTcp.ts | 4 +- entry/src/main/ets/common/utils/TcpClient.ts | 42 ++++++----- .../src/main/ets/entryability/EntryAbility.ts | 2 + entry/src/main/ets/pages/CarCheck.ets | 20 ++++- entry/src/main/ets/pages/UserInfo.ets | 12 ++- .../ets/pages/judgeSDK/utils/filePhoto.ts | 2 +- .../ets/pages/judgeSDK/utils/judgeConfig.ts | 6 +- 11 files changed, 125 insertions(+), 64 deletions(-) diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index e67b72af..2bf136fa 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -287,7 +287,10 @@ export async function takePhotoFn(context) { console.log('拍照失败') return } + console.log('takePhototakePhoto',JSON.stringify(data)) const zdyz=globalThis.param854Str?Number(globalThis.param854Str):Number(param.zdyz) + console.log('takePhototakePhoto',JSON.stringify(zdyz),) + if (Number(data.fileSize) <= (zdyz * 1000)) { map[key1] = true promptAction.showToast({ diff --git a/entry/src/main/ets/common/service/videoService.ts b/entry/src/main/ets/common/service/videoService.ts index 92ed5bd5..209686e4 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?,index?) { +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?,index?) { if (!path) { fileName = `movie_record${num}.mp4` } else { - fileName = `${path}_${index||num}.mp4` + fileName = `${path}_${index || num}.mp4` } // @ts-ignore @@ -99,20 +99,20 @@ export async function saveStartRecordVideo(path) { } for (let i = 1; i <= 4; i++) { if (param['videoRecord'+i]) { - console.log('pathpath0',path) + console.log('pathpath0', path) - record_handle[i] = await getfilehandleCode(i, param, date, path,i) + record_handle[i] = await getfilehandleCode(i, param, date, path, i) } } reslove(record_handle) }) } -async function getfilehandleCode(td, param, dir, path,index) { +async function getfilehandleCode(td, param, dir, path, index) { return new Promise(async (reslove, reject) => { - console.log('pathpath1',path) + console.log('pathpath1', path) - const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path,index) + const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path, index) // this.rocordHandleObj['rocord_handle'+td] = record_handle reslove(record_handle) }) @@ -120,7 +120,7 @@ async function getfilehandleCode(td, param, dir, path,index) { } -export async function getUserAlbumItemByDisplayName(displayName: string,day?,type?): Promise { +export async function getUserAlbumItemByDisplayName(displayName: string, day?, type?): Promise { let fetchResult = null let album: photoAccessHelper.Album = null try { @@ -137,10 +137,10 @@ export async function getUserAlbumItemByDisplayName(displayName: string,day?,typ console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult)); if (fetchResult.getCount() > 0) { const albums = await fetchResult.getLastObject(); - console.log('get getUserAlbumItemByDisplayName album111',albums.albumName) + console.log('get getUserAlbumItemByDisplayName album111', albums.albumName) - if(isSevenDaysAgo(albums.albumName,day)){ - deleteAllFileByPiC(albums.albumName,type) + if (isSevenDaysAgo(albums.albumName, day)) { + deleteAllFileByPiC(albums.albumName, type) } console.log('get getUserAlbumItemByDisplayName album',) } @@ -178,8 +178,33 @@ interface takePhotoParam { */ const fileHelper = new FileHelper(); -export async function takePhoto(param, context, dir, flag = 1, callback?) { +export async function delPic(day,type) { + let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(globalThis.context); + console.info('albumGetAssetsDemoCallback'); + let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); + let albumFetchOptions: photoAccessHelper.FetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let fetchOption: photoAccessHelper.FetchOptions = { + fetchColumns: [], + predicates: predicates + }; + let albumList: photoAccessHelper.FetchResult = await phAccessHelper.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, albumFetchOptions); + let albums = await albumList.getAllObjects(); + for(let i=0;i<=albums.length;i++){ + let albumName=albums[i].albumName + console.log('albumNamealbumName',albumName) + if (isSevenDaysAgo(albumName, day)&&albumName!='jt'&&albumName!='pz') { + deleteAllFileByPiC(albums.albumName, 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`; @@ -195,26 +220,31 @@ export async function takePhoto(param, context, dir, flag = 1, callback?) { console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize); callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode }) }); - } else { console.log('baoyihubaoyihu1', video_uri, flag) return new Promise(async (resolve, reject) => { const time = await getCurrentTime() const date = time.split(' ')[0] - rtsp_server.getVideoSnapshot(context, video_uri, fileName, date, true, (err, snapResult) => { + await fileHelper.createAlbum(date) + rtsp_server.getVideoSnapshot(context, video_uri, fileName, '/jt', true, (err, snapResult) => { console.log('baoyihubaoyihu', video_uri, flag, JSON.stringify(snapResult)) console.log('getPhtot', JSON.stringify(snapResult)) - resolve({ - base64: snapResult.dataString, - name: snapResult.fileName, - fileSize: snapResult.fileSize, - errorCode: snapResult.errorCode - }) + if(snapResult.result&&snapResult.errorCode==0){ + resolve({ + base64: snapResult.dataString, + name: snapResult.fileName, + fileSize: snapResult.fileSize, + errorCode: snapResult.errorCode + }) + }else{ + takePhoto(param, context, dir, flag, callback) + + // reject() + } + }); }) - console.log('getmyLog02') - } console.log('getmyLog03') diff --git a/entry/src/main/ets/common/utils/File.ts b/entry/src/main/ets/common/utils/File.ts index d13676dc..310eaf27 100644 --- a/entry/src/main/ets/common/utils/File.ts +++ b/entry/src/main/ets/common/utils/File.ts @@ -78,19 +78,24 @@ export default class FileUtil{ * @desc 创建或者编辑文件 * */ + public openFileSync=async(filePath)=>{ + const { READ_WRITE,CREATE,APPEND }= fs.OpenMode + let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE); + return file + } + + public editFileWidthOutOpen(file,content){ + const newStr = content + '\n' + fs.writeSync(file.fd,newStr) + fs.closeSync(file) + console.error(LOGTAG,'写入文件成功') + } + + public editFile = async (filePath:string,content:string,type?:string)=>{ const { READ_WRITE,CREATE,APPEND }= fs.OpenMode try { let file = fs.openSync(filePath, READ_WRITE | APPEND |CREATE); - let index - // if(type=='overWrite'){ - // //文件覆蓋 - // index=0 - // }else{ - // //文件追加 - // const str = fs.readTextSync(filePath); - // index= str.length - // } const newStr = content + '\n' //追加写入文件 fs.writeSync(file.fd,newStr) diff --git a/entry/src/main/ets/common/utils/GetDistance.ts b/entry/src/main/ets/common/utils/GetDistance.ts index 44293408..4279133c 100644 --- a/entry/src/main/ets/common/utils/GetDistance.ts +++ b/entry/src/main/ets/common/utils/GetDistance.ts @@ -61,6 +61,7 @@ export default class GetDistance { setInterval(()=>{ const { carId } = globalThis.carInfo; const {date,timeStr,totalDistance}= this; + return //"carid":"1001","startTime":"2024-08-24 08:09:01","time":"111233", "mileage":"1222" uploadHarmonyLiCheng({ carid:carId, diff --git a/entry/src/main/ets/common/utils/GlobalTcp.ts b/entry/src/main/ets/common/utils/GlobalTcp.ts index 0c526557..0c1ecb49 100644 --- a/entry/src/main/ets/common/utils/GlobalTcp.ts +++ b/entry/src/main/ets/common/utils/GlobalTcp.ts @@ -3,7 +3,7 @@ import { getSyncData } from '../service/initable'; import hilog from '@ohos.hilog'; import FileUtil from '../../common/utils/File' import { GlobalConfig } from '../../config/index' -export async function getTCP() { +export async function getTCP(flag=false) { const fileUtil = new FileUtil(globalThis.context) const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/ipConfig.txt'); if (data === '' || data === undefined) { @@ -12,7 +12,7 @@ export async function getTCP() { } }else{ const result=JSON.parse(data) - if (globalThis.TcpClient && globalThis.TcpClient.closeTcp) { + if (globalThis.TcpClient && globalThis.TcpClient.closeTcp&&!flag) { globalThis.TcpClient.closeTcp(async () => { // const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort) // globalThis.TcpClient = tcpClient diff --git a/entry/src/main/ets/common/utils/TcpClient.ts b/entry/src/main/ets/common/utils/TcpClient.ts index fc14314c..04acdb94 100644 --- a/entry/src/main/ets/common/utils/TcpClient.ts +++ b/entry/src/main/ets/common/utils/TcpClient.ts @@ -33,6 +33,8 @@ export default class TcpClient { // time:dateFormat(new Date()), // PLC:`${TAG} tcpOnerror ${JSON.stringify(err)}`, // }) + globalThis.getCloseTcp = true + this.writeLog({ time:dateFormat(new Date()), message: `${TAG} tcponerror localIp${JSON.stringify(err)}`, @@ -62,6 +64,9 @@ export default class TcpClient { time:dateFormat(new Date()), message: `${TAG} tcprebind tcpreBinderror${JSON.stringify(err)}`, }) + setTimeout(async () => { + getTCP() + }, 2000) // globalThis.getCloseTcp = true hilog.info(0x0000, 'testTag', "tcpreBinderror:" + JSON.stringify(err)); resolve(true) @@ -104,13 +109,14 @@ export default class TcpClient { time:dateFormat(new Date()), message: `${TAG} tcpbind error ${JSON.stringify(err)}`, }) + setTimeout(async () => { + getTCP() + }, 2000) console.log('testTag tcp bind faile'); - // globalThis.getCloseTcp = true hilog.info(0x0000, 'testTag', "tcpBinderror:" + JSON.stringify(err)); resolve(true) return } - // globalThis.getCloseTcp = false console.log('testTag tcp bind success'); // this.writeLog({ // time:dateFormat(new Date()), @@ -152,13 +158,12 @@ export default class TcpClient { time:dateFormat(new Date()), message: `${TAG} TCPconnect error ${JSON.stringify(err)}`, }) + // this.writeLog({ // time:dateFormat(new Date()), // PLC:`${TAG} tcp connect rebind success`, // }) - if(this.num>3){ - return - } + setTimeout(() => { this.writeLog({ time:dateFormat(new Date()), @@ -166,7 +171,7 @@ export default class TcpClient { }) getTCP() resolve(false) - }, 2000) + }, 9000) return; } }); @@ -180,14 +185,11 @@ export default class TcpClient { message: `${TAG} TCPconnect error2 ${JSON.stringify(err)}`, }) // globalThis.getCloseTcp = true - this.num++ - if(this.num>3){ - return - } + setTimeout(() => { getTCP() resolve(false) - }, 2000) + }, 9000) // this.writeLog({ // time:dateFormat(new Date()), // PLC:`${TAG} tcp connect error`, @@ -205,10 +207,11 @@ export default class TcpClient { promise.then(() => { reslove(true) }).catch(err => { - this.writeLog({ - time:dateFormat(new Date()), - message: `${TAG} TCPsend error ${JSON.stringify(err)}`, - }) + console.log(`${TAG} TCPsend error ${JSON.stringify(err)}`) + // this.writeLog({ + // time:dateFormat(new Date()), + // message: `${TAG} TCPsend error ${JSON.stringify(err)}`, + // }) reslove(false) }); }) @@ -222,10 +225,7 @@ export default class TcpClient { // }) console.log(TAG, 'Tcponmessage', value) globalThis.tcpUdpError = false - this.writeLog({ - time:dateFormat(new Date()), - message: `${TAG} Tcponmessage ,${value}`, - }) + // console.log('messageLengt',,value.message.length)) console.log('testTagtcpmsg') // console.log("on message, message:" + value.message+ ", remoteInfo:" ) @@ -275,7 +275,6 @@ export default class TcpClient { } closeTcp(callback) { - return new Promise((reslove, reject) => { console.log(TAG, 'tcpClose') let promise = this.tcp.close(); @@ -289,6 +288,9 @@ export default class TcpClient { callback() reslove(true) }).catch(err => { + setTimeout(async () => { + getTCP(true) + }, 9000) this.writeLog({ time:dateFormat(new Date()), message: `${TAG} tcpclose error ${JSON.stringify(err)}`, diff --git a/entry/src/main/ets/entryability/EntryAbility.ts b/entry/src/main/ets/entryability/EntryAbility.ts index cdd454b2..61797483 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ts +++ b/entry/src/main/ets/entryability/EntryAbility.ts @@ -30,6 +30,8 @@ export default class EntryAbility extends UIAbility { globalThis.deviceNo = ''; globalThis.hasAuth = false + // globalThis.judgeVersion ='2024.08.24.1' + // globalThis.version ='2023.12.13.01'; globalThis.version = GlobalConfig.version.jn.km3[0]; globalThis.judgeVersion = GlobalConfig.version.jn.km3[1]; diff --git a/entry/src/main/ets/pages/CarCheck.ets b/entry/src/main/ets/pages/CarCheck.ets index 952a38df..37d48153 100644 --- a/entry/src/main/ets/pages/CarCheck.ets +++ b/entry/src/main/ets/pages/CarCheck.ets @@ -313,8 +313,26 @@ export default struct Index { this.getCheckList() return } + + console.log('this.index',index,) that.passArray[index]=true - that.warnFlag[index]='2' + if(index==2){ + let flag=false + console.log('globalThis.spzd[key]',globalThis.spzd) + + for(let key in globalThis.spzd){ + console.log('globalThis.spzd[key]',globalThis.spzd[key]) + if(globalThis.spzd[key]){ + that.warnFlag[index]='1' + flag=true + } + } + if(!flag){ + that.warnFlag[index]='2' + } + }else{ + that.warnFlag[index]='2' + } that.passArray=JSON.parse(JSON.stringify(that.passArray)) that.warnFlag=JSON.parse(JSON.stringify(that.warnFlag)) index++ diff --git a/entry/src/main/ets/pages/UserInfo.ets b/entry/src/main/ets/pages/UserInfo.ets index 5c972f6b..e47b4bf5 100644 --- a/entry/src/main/ets/pages/UserInfo.ets +++ b/entry/src/main/ets/pages/UserInfo.ets @@ -23,8 +23,7 @@ import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import { judgeConfig } from './judgeSDK/utils/judgeConfig'; import { initJudgeUdp } from '../common/utils/UdpJudge'; import errorMsgDialog from './compontents/errorMsgDialog' -import { delHilog } from '../common/service/indexService'; -import { deleteAllFileByPiC, getUserAlbumItemByDisplayName } from '../common/service/videoService'; +import { delPic } from '../common/service/videoService'; import { getCurrentHourTime } from '../common/utils/tools'; @Entry @Component @@ -489,8 +488,8 @@ struct UserInfo { } console.log('Param305Str',that.systemParam.Param305Str) // delHilog(this.Param305Str) - getUserAlbumItemByDisplayName('', that.systemParam.Param305Str,1) - getUserAlbumItemByDisplayName('',that.systemParam.Param305Str,2) + delPic(that.systemParam.Param305Str,1) + delPic(that.systemParam.Param305Str,2) } }) @@ -879,6 +878,11 @@ struct UserInfo { const date = new Date() globalThis.startHourTime = await getCurrentHourTime() const photoBase64 = await this.getPhoto(); + if(photoBase64==''){ + this.ksksLimit=false + this.isLoadingPopupVisible=false + return + } const drvexam = { lsh: this.currentUser.lsh || '', kskm: examSubject, diff --git a/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ts b/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ts index 34187c70..7961b98e 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/filePhoto.ts @@ -44,7 +44,7 @@ export default class FilePhoto{ return res.base64 } catch (e) { promptAction.showToast({ - message: '拍照异常' + JSON.stringify(e), + message: '拍照异常,请重新' + JSON.stringify(e), duration: 2000 }); return '' diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts index 3d90118a..2b4d9986 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts @@ -1,4 +1,3 @@ - //考试回放开关 export const judgeConfig = { //本地目录开关 @@ -9,7 +8,6 @@ export const judgeConfig = { kfVoiceOpen: false, //忽略的考试项目 ignoreProjects:[], - // 是否忽略考试前熄火、车门检查 isCheckFireOpen: true, //轨迹回放是否开启Udp @@ -17,14 +15,12 @@ export const judgeConfig = { // 本地模型地址 modelPath: 'models/model_enc', // 济南科目三 - trajectoryPath: 'logs/2024_12_05/2024_12_05_14_35_24_0000000000000_342323199501470011_测试学员1/judge_exam_data.txt', + trajectoryPath: 'logs/2024_12_20/2024_12_20_15_10_30_9999920215968_355757250887519616_段士婕/judge_exam_data.txt', //四合一画面配置 fourInOneScreen:{ //gps位数 gpsDigit:6 }, - //后置机类型 0=>三代机 1=>一体机 2=>二代机 - rearEndUnitsType:0, // 杭州科目二 // trajectoryPath: 'logs/2024_07_19/0000000000001_342323199501470011_测试学员1_2024_07_19_06_49_12/judge_exam_data.txt', //TODO 济南临时特殊配置