dengsixing 1 napja
szülő
commit
9635acf902

+ 14 - 1
src/main/java/com/fdkankan/scene/service/impl/NjsSceneBoxModelServiceImpl.java

@@ -53,6 +53,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.time.Instant;
@@ -235,7 +236,19 @@ public class NjsSceneBoxModelServiceImpl extends ServiceImpl<INjsSceneBoxModelMa
                 o -> ((JSONObject)o).getLong("createTime"),
                 Comparator.nullsLast(Long::compareTo)
         ).reversed());
-        fYunFileService.uploadFile(JSON.toJSONString(collect).getBytes(StandardCharsets.UTF_8), njsBoxModelKey);
+        String localNjsModelJsonPath = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "njsBoxModels.json";
+        try (FileWriter writer = new FileWriter(localNjsModelJsonPath)) {
+            for (JSONObject jsonObject : collect) {
+                // 一行一个JSON,严格按照集合顺序写入
+                writer.write(jsonObject.toJSONString());
+                writer.write("\n"); // 换行
+            }
+            fYunFileService.uploadFile(localNjsModelJsonPath, njsBoxModelKey);
+        }finally {
+            FileUtil.del(localNjsModelJsonPath);
+        }
+
+
     }
 
     @Override