|
@@ -70,7 +70,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.FileSystemResource;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -357,19 +360,9 @@ public class CaseLogicImpl implements CaseLogic {
|
|
|
*/
|
|
|
private void save2crowdPlatform(String fileUrl, String paper_type, String test_type, String
|
|
|
description, long caseId, String caseName) throws Exception {
|
|
|
- String tmpPath = System.getProperty("java.io.tmpdir");
|
|
|
- String crowdSavePath = Constants.CROWD_SAVE_PATH;
|
|
|
- String tmpCrowdDir = Paths.get(tmpPath, crowdSavePath).toString();
|
|
|
String filename = fileUrl.split("/")[fileUrl.split("/").length-1];
|
|
|
- boolean success = ossLogic.downloadByUrl(fileUrl,tmpCrowdDir, filename);
|
|
|
- if(!success){
|
|
|
- throw new ServerException(60000, "保存到众测时,从oss下载文件失败");
|
|
|
- }
|
|
|
-
|
|
|
- FileSystemResource excelFile = new FileSystemResource(new File(Paths.get
|
|
|
- (tmpCrowdDir, filename).toString()));
|
|
|
- MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
|
- params.add("file", excelFile);
|
|
|
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
+ params.add("file", fileUrl);
|
|
|
params.add("file_name", filename);
|
|
|
params.add("paper_type", paper_type);
|
|
|
params.add("case_id", caseId+"");
|
|
@@ -380,7 +373,7 @@ public class CaseLogicImpl implements CaseLogic {
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
|
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity
|
|
|
- (crowdAddress+"/Bug/api/extra/uploadExam", params, String.class);
|
|
|
+ (crowdAddress+"/Bug/api/extra/uploadExamUrl", params, String.class);
|
|
|
if(responseEntity.getStatusCode().equals(HttpStatus.OK)){
|
|
|
InputStream jsonInputStream = new ByteArrayInputStream(responseEntity.getBody().getBytes());
|
|
|
ossLogic.uploadByUrl(bucketName, "json/"+caseId+".json", jsonInputStream);
|