dengsixing 3 năm trước cách đây
mục cha
commit
cdc044eda4

+ 1 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/constant/FileBizType.java

@@ -10,6 +10,7 @@ public enum FileBizType {
     FLOOR_PLAN("floorPlan", "户型图"),
     SCREENSHOT("screenshot", "初始画面"),
     BOX_VIDEO("box-video", "视频"),
+    TAG_ICON("tag-icon", "热点图标"),
     LINK_STYLE("link-style", "场景关联图标")
     ;
 

+ 34 - 38
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/TestUtil.java

@@ -2,9 +2,12 @@ package com.fdkankan.common.util;
 
 import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.img.ImgUtil;
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.constant.TbStatus;
 import java.awt.Image;
 import java.io.File;
@@ -14,6 +17,10 @@ import java.util.Calendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
 import java.util.function.Consumer;
 
 /**
@@ -35,43 +42,32 @@ public class TestUtil {
         residenceServiceHostName.add("bbb");
     }
 
-    public static void main(String[] args) {
-//        System.out.println(residenceServiceHostName.contains(hostName));
-//        Map<String, String> map = new HashMap<>();
-//        map.put("1","a");
-//        map.entrySet().stream().forEach(System.out::println);
-
-//        JSONArray jsonArray = new JSONArray();
-//        jsonArray.add(1);
-//        Integer[] arr = new Integer[jsonArray.size()];
-//        jsonArray.toArray(arr);
-//        Arrays.stream(arr).forEach(System.out::println);
-
-
-//        cn.hutool.core.io.FileUtil.del("F:\\test1");
-
-//        cn.hutool.core.io.FileUtil.copyFile("F:\\test", "F:\\test2");
-
-//        List<String> list = new ArrayList<>();
-//        for(int i = 1; i < 999; i++){
-//            list.add("" + i);
-//        }
-//
-//        ListUtil.page(list, 100, new Consumer<List<String>>() {
-//            @Override
-//            public void accept(List<String> strings) {
-//                for (String string : strings) {
-//                    System.out.println("a" + string);
-//                }
-//            }
-//        });
-
-        long start = Calendar.getInstance().getTimeInMillis();
-        String srcPath = "F:\\test\\4.jpg";
-        String desPath = "F:\\test\\4_b.jpg";
-        ImgUtil.scale(new File(srcPath), new File(desPath), 512, 256, null);
-        System.out.println(Calendar.getInstance().getTimeInMillis() - start);
-
+    public static void main(String[] args) throws Exception {
+        String s = FileUtils.readFile("F:\\test\\link-scene.json");
+        JSONObject jsonObject = JSON.parseObject(s);
+        JSONArray tags = jsonObject.getJSONArray("tags");
+        ExecutorService executorService = Executors.newFixedThreadPool(5);
+        List<Future> futureList = new ArrayList<>();
+        for (Object tag : tags) {
+            Callable<Boolean> call = new Callable() {
+                @Override
+                public Boolean call() throws Exception {
+                    JSONObject tag1 = (JSONObject) tag;
+                    String path = tag1.getString("path");
+                    if(StrUtil.isNotEmpty(path)){
+                        tag1.put("path", path.replace("4k", "123"));
+                    }
+                    return true;
+                }
+            };
+            futureList.add(executorService.submit(call));
+        }
+        //这里一定要加阻塞,不然会导致oss文件还没打包好,主程序已经结束返回了
+        for (Future future : futureList) {
+            future.get();
+        }
+
+        System.out.println(JSON.toJSONString(jsonObject));
 
 
     }