Browse Source

修改数据导出的文件路径

xujiawei 4 years ago
parent
commit
652e70a11e

+ 2 - 0
.gitignore

@@ -27,3 +27,5 @@ HELP.md
 
 ### VS Code ###
 .vscode/
+
+.DS_Store

+ 1 - 1
src/main/java/edu/nju/controller/OssController.java

@@ -51,7 +51,7 @@ public class OssController {
     @ResponseBody
     public String ossUpload(@RequestParam("file") MultipartFile file, String path,String caseId) {
 //        File dest = new File("/Users/xujiawei/crowd/crowdsource-backend/src/main/java/edu/nju/controller" + path);
-        File dest = new File("/data/image/"+caseId+"/" + path);
+        File dest = new File("/xinchuangdata/image/"+caseId+"/" + path);
         if(!dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); }
         try {
             if(!file.isEmpty()) { file.transferTo(dest); }

+ 7 - 3
src/main/java/edu/nju/service/DataService.java

@@ -227,7 +227,9 @@ public class DataService {
         //导出图片zip包
         String sourceFile = "/data/image/" + caseId;
         try {
-            FileOutputStream fileOutputStream = new FileOutputStream(new File("/data/imageZip/" + caseId + ".zip"));
+            File dest = new File("/xinchuangdata/imageZip/" + caseId + ".zip");
+            if(!dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); }
+            FileOutputStream fileOutputStream = new FileOutputStream(dest);
             toZip(sourceFile, fileOutputStream, false);
         } catch (FileNotFoundException e) {
             e.printStackTrace();
@@ -238,7 +240,8 @@ public class DataService {
 
     private void exportJson(List<BugDetail> bugDetailList, String caseId) {
         try {
-            File file = new File("data/output/" + caseId + "/" + caseId + ".json");
+            File file = new File("xinchuangdata/output/" + caseId + "/" + caseId + ".json");
+            if(!file.getParentFile().exists()) { file.getParentFile().mkdirs(); }
             JSONArray jsonArray = new JSONArray(bugDetailList);
             Writer write = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
             write.write(jsonArray.toString());
@@ -252,7 +255,8 @@ public class DataService {
 
     private <T> void exportCsv(String[] titles, List<T> list, String caseId) {
         try {
-            File file = new File("data/output/" + caseId + "/" + caseId + ".csv");
+            File file = new File("xinchuangdata/output/" + caseId + "/" + caseId + ".csv");
+            if(!file.getParentFile().exists()) {file.getParentFile().mkdirs(); }
             //构建输出流,同时指定编码
             OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
             //csv文件是逗号分隔,除第一个外,每次写入一个单元格数据后需要输入逗号