|
@@ -10,6 +10,7 @@ import org.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.lang.reflect.Field;
|
|
@@ -174,7 +175,7 @@ public class DataService {
|
|
|
return bugDetailList;
|
|
|
}
|
|
|
|
|
|
- public List<BugDetail> saveBugDetailFromOss(String zipFilePath,String jsonFilePath, String originalCaseId, String cpSerialNum) {
|
|
|
+ public List<BugDetail> saveBugDetailFromOss(MultipartFile sourceZipFile, MultipartFile sourceJsonFile, String originalCaseId, String cpSerialNum) {
|
|
|
try {
|
|
|
// //从oss下载json文件
|
|
|
// URL url = new URL(jsonFilePath);
|
|
@@ -183,9 +184,17 @@ public class DataService {
|
|
|
// httpURLConnection.setConnectTimeout(1000 * 5);
|
|
|
// httpURLConnection.setRequestProperty("Charset", "UTF-8");
|
|
|
// httpURLConnection.connect();
|
|
|
- //读取本地文件
|
|
|
+
|
|
|
+ //读取文件流并保存在本地
|
|
|
+ String zipFilePath="xinchuangdata/input/imageZip/"+originalCaseId+"/"+cpSerialNum+"/"+originalCaseId+".zip";
|
|
|
+ File zipFile=new File(zipFilePath);
|
|
|
+ if(!zipFile.getParentFile().exists()) { zipFile.getParentFile().mkdirs(); }
|
|
|
+ if(!sourceZipFile.isEmpty()) { sourceZipFile.transferTo(zipFile); }
|
|
|
+ String jsonFilePath="xinchuangdata/input/"+originalCaseId+"/"+cpSerialNum+"/"+originalCaseId+".json";
|
|
|
File jsonFile=new File(jsonFilePath);
|
|
|
-// BufferedInputStream bufferedInputStream = new BufferedInputStream(httpURLConnection.getInputStream());
|
|
|
+ if(!jsonFile.getParentFile().exists()) { jsonFile.getParentFile().mkdirs(); }
|
|
|
+ if(!sourceJsonFile.isEmpty()) { sourceJsonFile.transferTo(zipFile); }
|
|
|
+ //读取本地文件
|
|
|
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(jsonFile));
|
|
|
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
|
|
int result = bufferedInputStream.read();
|
|
@@ -212,8 +221,7 @@ public class DataService {
|
|
|
bugDetailDao.save(bugDetail);
|
|
|
}
|
|
|
//解压图片文件,上传至oss
|
|
|
- File zipFile=new File(zipFilePath);
|
|
|
- String destPath="xinchuangdata/imageUnzip/"+originalCaseId+"/"+cpSerialNum;
|
|
|
+ String destPath="xinchuangdata/input/imageUnzip/"+originalCaseId+"/"+cpSerialNum;
|
|
|
File unzipFile=new File(destPath);
|
|
|
if(!unzipFile.getParentFile().exists()) { unzipFile.getParentFile().mkdirs(); }
|
|
|
unZip(zipFile,destPath,originalCaseId,cpSerialNum);
|