diff --git a/uniappWWW/unipluginDemo/utils/8inFileOperate.js b/uniappWWW/unipluginDemo/utils/8inFileOperate.js index b5fd1bc..1574782 100644 --- a/uniappWWW/unipluginDemo/utils/8inFileOperate.js +++ b/uniappWWW/unipluginDemo/utils/8inFileOperate.js @@ -1,6 +1,13 @@ import downloadImg from "./download.js" /* +*V1.0 +*基于5+ IO 封装的基础文件操作库 业务函数 为人脸识别操作提供文件处理功能 +*使用范围:(7in,8in)Android 11 Pad +*更新日期:2022/06/09 +*/ + +/* fileName: 需要查询的目录名 */ async function getFileChildrenList(fileName){ @@ -20,6 +27,7 @@ async function getFileChildrenList(fileName){ fileName: 需要删除的文件名 */ async function deleteAndroidFaceImage(fileName){ + console.log("deleteAndroidFaceImage:",fileName) let item = { "deleteFile" : true, "name": fileName @@ -60,6 +68,9 @@ async function deleteAndroidFaceImage(fileName){ */ async function downloadFileList(res){ // await asyncSetTimeOut(3000) //延时,手动断网,模拟下载失败 + let clearUNI = await clearUniDownloadFace(); + console.log("清空doc结果:",clearUNI) + return new Promise(async(rs,rj)=>{ let {list,request_time,total} = res console.log(request_time,total); @@ -182,8 +193,8 @@ async function downloadFileImg(item) { let delResult = await downloadImg.removeFile(newNameFileEntry); //删除已存在的文件 } - let reNamePathEntry = await downloadImg.moveFileTo(savedFilePathEntry, faceSyncEntry, newName); //重命名文件到人脸库同步文件夹 - // console.log(savedFilePath,newName,reNamePathEntry.fullPath) + let reNamePathEntry = await downloadImg.moveFileTo(savedFilePathEntry, faceSyncEntry, newName); //重命名文件到人脸库同步文件夹 + console.log("重命名后:",savedFilePath,newName,reNamePathEntry.fullPath) return reNamePathEntry.fullPath; } @@ -211,7 +222,25 @@ async function clearDownloadFace(fileName){ await downloadImg.removeFileAll(newNameFileEntry).then(e=>{ console.log(fileName,"删除:",e); }) -} +} +//递归清空本地临时下载目录及子目录 +async function clearUniDownloadFace(){ + let fs = await downloadImg.requestFileSystem(plus.io.PRIVATE_DOC); //获取所要操作根目录File System + + // let faceSyncEntry = await downloadImg.getDirectory({ + // //在PUBLIC_DOWNLOADS下定义人脸库同步文件夹[fileName] + // OriginPathEntry: fs.root, + // newFileName: fileName + // }); + // let newNameFileEntry = await downloadImg.resolveLocalFileSystemURL(faceSyncEntry.fullPath).catch( + // e => { + // console.log('操作目标文件', e); + // }); + await downloadImg.removeFileAll(fs).then(e=>{ + console.log("删除uni _Doc缓存文件:",e); + }) +} + module.exports = { downloadFileImg, clearDownloadFace, diff --git a/uniappWWW/unipluginDemo/utils/download.js b/uniappWWW/unipluginDemo/utils/download.js index 0a3b56d..aa9241b 100644 --- a/uniappWWW/unipluginDemo/utils/download.js +++ b/uniappWWW/unipluginDemo/utils/download.js @@ -1,3 +1,10 @@ +/* +*V1.0 +*基于5+ IO 封装的基础文件操作库 +*更新日期:2022/06/09 +*/ + + let downloadTask; diff --git a/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TCPTask.java b/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TCPTask.java index 1e4cda1..bbe93ca 100644 --- a/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TCPTask.java +++ b/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TCPTask.java @@ -34,6 +34,11 @@ public class TCPTask { public void task(final Integer port, final UniJSCallback uniJSCallback){ // System.out.println("AsyncTask thread running... ==>>>44444444:"+port+ server.isServerBound()); + + System.out.println("task666:"+port+ server); + if(server!=null){ + return; + } this.server = new TcpServer(); // this.server = server.initSocket(port,uniJSCallback); @@ -69,19 +74,16 @@ public class TCPTask { // myCallback.tcpCallback(data); // myTcpCallback.tcpCallback(data);//回调到zmtClass给uni端 uniJSCallback.invokeAndKeepAlive(data); - try { - Thread.sleep(100); //定义休眠时间 - } catch (InterruptedException e) { - e.printStackTrace(); - } + System.out.println(TAG+"已回调给UNI信息:"+data.toJSONString()); + }else{ - try { - Thread.sleep(1000); //定义休眠时间 - } catch (InterruptedException e) { - e.printStackTrace(); - } - } + } + try { + Thread.sleep(1000); //定义休眠时间 + } catch (InterruptedException e) { + e.printStackTrace(); + } } diff --git a/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TcpServer.java b/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TcpServer.java index ec54435..62ebf76 100644 --- a/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TcpServer.java +++ b/zmt_module/src/main/java/io/dcloud/zmt_module/tcpServer/TcpServer.java @@ -206,6 +206,11 @@ public class TcpServer { Runnable mRunnable = new Runnable() { @Override public void run() { + + if(mServer==null){ + return; + } + System.out.println(TAG+"TCP mServer :"+mServer); try { mOutStream = mServer.getOutputStream(); mPrinter = new PrintWriter(new OutputStreamWriter(mOutStream,Charset.forName(charsetName)));