Selaa lähdekoodia

功能查找优化

guilin 1 kuukausi sitten
vanhempi
commit
aa4db8f480

+ 14 - 84
app/src/main/java/com/fxy/common/AsyncPictureUpload.java

@@ -52,6 +52,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 import io.reactivex.functions.Consumer;
@@ -411,97 +412,26 @@ public class AsyncPictureUpload {
     //临时处理数据用
     private void tmpData(){
         if (awaitUploadList.size()==0 && debug){
-            String[] ossUrlList = {
-                    "/uat/fxy/android/tally/20240924/57058c6a-6f59-4e6d-a93c-7a8044f9a721.JPEG"
-
-                    ,"/prod/fxy/android/detection/20240923/d3e5552e-344c-4c74-be91-468cbb22f22c.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/893d8514-de5a-44bd-822a-c82959d11913.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/d0346866-d994-476c-8229-06aadb118eea.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/8d4f6893-e325-433a-9f78-0844d7b6b331.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/ac92069b-895e-45ad-b507-0494336be03a.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/3f2cd16c-59fb-40d5-bcf3-c969f7cbbb5c.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/47ef4d43-6fe6-4040-a5ec-8b9732ba5100.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/39284eae-b033-4e7d-a17c-e85c43931b6c.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/bd8c0f51-c211-458e-80d2-591b3fd7f25b.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/33f57a98-b86d-4b11-aca5-142042acfa77.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/4b611cbf-6273-43e1-81b0-120cf86dca53.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/63910671-cda0-4baf-a430-8bd3776c199a.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/b7e4125c-1c9b-4146-a11d-f2685c18e51f.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/5aeab08a-e938-4645-919b-41bcf3791502.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/f2d52733-2e21-4a54-9134-8cdf2ea2557b.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/0db0c21d-7b24-4781-95de-102ef7845ec8.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/3f81cbae-1b1e-4c6c-8f11-8a1c7c786f2f.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/289d314e-ad49-4c42-8be9-8156e6c673bd.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/73b82d21-1722-4692-94f5-b001c0b36fe9.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/9bd4bebb-04a4-4999-aefc-11092bafe653.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/9124f3ce-ab63-43f2-9e7c-d1b8fe037e65.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/b4931917-6851-4c18-82d3-f9010b81d84b.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/dbcc7133-793c-441e-9ef8-d4126372fc3d.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/cac07313-17e7-4ec4-b73b-cb8e42d171fa.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/e81da115-731b-418d-ba6d-ceac8f4eba7e.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/fdc1ee7d-1a56-4ee7-ac93-adba19df2845.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/92ccee22-a2ff-4e09-a836-238a8dc1f1cc.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/f9e6dcb4-62bd-425b-baf2-8db75c72223d.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/fe5fe3a3-595d-4127-96d1-6671e356a4fd.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/8bdc775d-bbd8-433d-a757-bf1523c9d3ff.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/29fc2776-9bdd-4c61-bf6e-21d1a6928bdc.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/e910bfbf-4110-4b96-a711-1323d76763fe.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/bfa8001a-c5e7-4db4-bd16-1d977fb9dae5.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/1fab9a47-51ee-4e73-9058-0a65e147d557.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/9d1a3561-4918-40fa-a44a-21a552936182.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/ce70f7f9-bcc1-452a-b4cf-cd583b4f62bf.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/68e40cfe-9e64-4258-8fb5-c3c160942247.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/4148331e-0b6e-4343-8fcf-a1f8e4ec8d8a.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/d5ceb788-7f9e-41c5-921f-a4ea4b7d17f8.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/2b05c0fe-8a1e-4fa3-8481-58877b6eda5e.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/dda38490-feaf-42d3-b6f9-c260a4915cc0.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/74587b04-3a0f-4d60-a009-7b6d77d7d302.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/d2feeeee-5078-49cc-934f-cedc794c8888.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/d6b76b2c-d778-4fa2-9485-c5f34142c7ce.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/b156f5a8-74a4-4329-9791-463acebabf34.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/56ac3bd7-3e06-4b1f-84c0-ff83571cc4d5.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/7f296e23-309a-4453-96b8-66403b04b73a.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/20cd6d0d-73dd-4ecf-b8e8-34110a0fa619.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/96a7b5ef-cbcf-4550-89b3-fea48579e34e.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/06aef90f-2714-49c2-8371-02ea218b7962.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/a50fc133-9a01-4cb6-97e4-476c93d86723.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/1f4218ee-3fe2-47dd-a9f9-ac65fa00c44c.JPEG"
-                    ,"/prod/fxy/android/detection/20240924/0022e008-ba82-4e0e-9c80-4888a22c7c7e.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/c31f4fe2-e797-4926-8cd5-15db2e5eac59.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/4498de19-c6b2-44f3-b37d-ea0989230ba1.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/df7e573a-121c-46cc-bdfb-311c1a4b6a5e.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/9e4dbdc0-8a75-4518-9cf7-9b0194a42cde.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/9021c9b5-e17c-49c1-85d9-7773be136c7b.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/e7fe892c-c26f-4849-9957-f9bdf34a5f29.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/37e739c0-a2bc-4d86-a379-a3d00b773d41.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/2a301b28-9ced-460b-9e2c-da6520c39518.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/47da0be7-d528-4fc2-ad3d-cad9f4f456af.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/e46b2289-2d3a-4709-860c-6a48e48611f4.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/70b2c33d-7991-4cf5-99d6-69ee21f0200f.JPEG"
-                    ,"/prod/fxy/android/detection/20240923/c0065364-7fdc-4eb5-be13-8c630ecf3b59.JPEG"
-            };
-            long timestamp = getNextTimestamp(-6);
-            for (int i = 0; i < ossUrlList.length; i++) {
-                String ossUrl = ossUrlList[i];
-                String[] tmpOssUrl = ossUrl.split("/");
-                String likeOssUrl = tmpOssUrl[tmpOssUrl.length-1];
 
+            HashMap<String,String> mapUrl= new HashMap<>();
+            mapUrl.put("dd31ae2f-dd02-46b2-bfdb-eb721ea11066","/prod/fxy/android/detection/20240923/d3e5552e-344c-4c74-be91-468cbb22f22c.JPEG");
+
+            // 使用entrySet()遍历
+            for (Map.Entry<String, String> entry : mapUrl.entrySet()) {
+                System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue());
+
+                String realmId = entry.getKey();
+                String ossUrl = entry.getValue();
                 mRealm.beginTransaction();
                 RealmResults<AsyncUploadRealm> realmResults ;
 
                 RealmQuery<AsyncUploadRealm> queryRealm =  mRealm.where(AsyncUploadRealm.class)
-                        .like("ossUrl", "%"+likeOssUrl+"%")
-                        .or()
-                        .equalTo("ossUrl", ossUrl.replace("detection", "tally"))
-                        .or()
-                        .equalTo("ossUrl", ossUrl)
-                        .greaterThan("createTime",  timestamp)
-                        ;
+                        .equalTo("id",  realmId);
                 realmResults = queryRealm.sort("createTime").findAll();
-
-
                 for (AsyncUploadRealm item : realmResults) {
-                    item.setOssUrl(ossUrl);
+                    if (!ossUrl.isEmpty()){
+                        item.setOssUrl(ossUrl);
+                    }
                 }
                 realmResults.load();
                 mRealm.commitTransaction();

+ 5 - 3
app/src/main/java/com/fxy/common/OssService.java

@@ -115,9 +115,9 @@ public class OssService {
         //OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(accessKeyId, accessKeySecret, "");
 
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setConnectionTimeout(120 * 1000); // 连接超时,默认15秒。
-        conf.setSocketTimeout(120 * 1000); // socket超时,默认15秒。
-        conf.setMaxConcurrentRequest(2); // 最大并发请求书,默认5个。
+        conf.setConnectionTimeout(240 * 1000); // 连接超时,默认15秒。
+        conf.setSocketTimeout(240 * 1000); // socket超时,默认15秒。
+        conf.setMaxConcurrentRequest(10); // 最大并发请求书,默认5个。
         conf.setMaxErrorRetry(3); // 失败后最大重试次数,默认2次。
         oss = new OSSClient(mContext, endpoint, credentialProvider, conf);
 
@@ -155,6 +155,8 @@ public class OssService {
         });
         thread.start();
 
+
+
         //new ossThread(filePath, uploadName , num,handler).start();
         // task.cancel(); // 可以取消任务
         // task.waitUntilFinished(); // 可以等待直到任务完成

+ 2 - 3
app/src/main/java/com/fxy/main/fragment/MineFragment.java

@@ -503,10 +503,9 @@ public class MineFragment extends BaseFragment {
 
             SPCache sp = SPCache.getInstance(getActivity());
             String newsFileName = RxTimeTool.getYestoryDate("MMddHHmmss")+fileName+"-"+sp.getUserName();
-            String path_prefix = sp.getResourcePrefix()+"/android/log/"+ RxTimeTool.getYestoryDate("yyyyMMdd")+"/";
 
-            FiledUpload filedUpload = new FiledUpload(getActivity(),"");
-            filedUpload.filedUpload(file.toString(),path_prefix+newsFileName);
+            FiledUpload filedUpload = new FiledUpload(getActivity(),"log");
+            filedUpload.filedUpload(file.toString(),newsFileName);
 
         }catch (Exception e){
             XLog.e("上传文件失败"+e.getMessage());