|
@@ -3,11 +3,6 @@ package com.mooctest.service;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.mongodb.MongoClient;
|
|
|
|
-import com.mongodb.client.FindIterable;
|
|
|
|
-import com.mongodb.client.MongoCollection;
|
|
|
|
-import com.mongodb.client.MongoCursor;
|
|
|
|
-import com.mongodb.client.MongoDatabase;
|
|
|
|
import com.mooctest.dao.MasterReportDao;
|
|
import com.mooctest.dao.MasterReportDao;
|
|
import com.mooctest.dao.TaskDao;
|
|
import com.mooctest.dao.TaskDao;
|
|
import com.mooctest.dao2.CrowdTaskDao;
|
|
import com.mooctest.dao2.CrowdTaskDao;
|
|
@@ -21,10 +16,8 @@ import org.bson.Document;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.http.HttpEntity;
|
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
+import org.springframework.core.io.ByteArrayResource;
|
|
|
|
+import org.springframework.http.*;
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
import org.springframework.http.converter.HttpMessageConverter;
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -267,6 +260,18 @@ public class TaskService {
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String addCrowdTaskPure(String name,String description,String time,String type,MultipartFile threePage){
|
|
|
|
+ if(threePage ==null || threePage.isEmpty()) return "请提交三级页面";
|
|
|
|
+ String threePageUrl = fileService.uploadFile(threePage);
|
|
|
|
+ try {
|
|
|
|
+ boolean flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),"",getMaxCaseId()+1,type,description,name);
|
|
|
|
+ return flag ?"success":"创建失败";
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return "创建众测失败";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public String addCrowdTask(String name,String description,String time,String type,String webUrl,MultipartFile apk,MultipartFile requirement,MultipartFile threePage){
|
|
public String addCrowdTask(String name,String description,String time,String type,String webUrl,MultipartFile apk,MultipartFile requirement,MultipartFile threePage){
|
|
if (requirement==null||requirement.isEmpty()) return "请提交需求文档";
|
|
if (requirement==null||requirement.isEmpty()) return "请提交需求文档";
|
|
if(threePage ==null || threePage.isEmpty()) return "请提交三级页面";
|
|
if(threePage ==null || threePage.isEmpty()) return "请提交三级页面";
|
|
@@ -336,9 +341,54 @@ public class TaskService {
|
|
temp=Long.parseLong(task.getId());
|
|
temp=Long.parseLong(task.getId());
|
|
max=temp>max?temp:max;
|
|
max=temp>max?temp:max;
|
|
}
|
|
}
|
|
-
|
|
|
|
// CrowdTask task = crowdTaskDao.findFirstByOrderByIdDesc();
|
|
// CrowdTask task = crowdTaskDao.findFirstByOrderByIdDesc();
|
|
-
|
|
|
|
return max;
|
|
return max;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean exportTask(String caseId){
|
|
|
|
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
|
+ params.add("caseId", caseId);
|
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
|
+ restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity
|
|
|
|
+ ("http://" + reportHost + "/Bug/api/data/outputByCaseId", params, String.class);
|
|
|
|
+ return responseEntity.getStatusCode().equals(HttpStatus.OK);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean importTask(String number,String originId,
|
|
|
|
+ MultipartFile zipFile, MultipartFile jsonFile) {
|
|
|
|
+
|
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
|
+ MediaType type = MediaType.parseMediaType("multipart/form-data");
|
|
|
|
+ // 设置请求的格式类型
|
|
|
|
+ headers.setContentType(type);
|
|
|
|
+ ByteArrayResource zipFileResource = null;
|
|
|
|
+ ByteArrayResource jsonFileResource = null;
|
|
|
|
+ try {
|
|
|
|
+ zipFileResource= new ByteArrayResource(zipFile.getBytes()) {
|
|
|
|
+ @Override
|
|
|
|
+ public String getFilename() {
|
|
|
|
+ return zipFile.getOriginalFilename();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ jsonFileResource= new ByteArrayResource(jsonFile.getBytes()) {
|
|
|
|
+ @Override
|
|
|
|
+ public String getFilename() {
|
|
|
|
+ return jsonFile.getOriginalFilename();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }catch (IOException e){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
|
|
+ params.add("sourceZipFile", zipFileResource);
|
|
|
|
+ params.add("sourceJsonFile", jsonFileResource);
|
|
|
|
+ params.add("originalCaseId", originId);
|
|
|
|
+ params.add("cpSerialNum", number);
|
|
|
|
+ HttpEntity<MultiValueMap<String, Object>> files = new HttpEntity<>(params, headers);
|
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
|
+ restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity("http://" + reportHost + "/Bug/api/data/inputFromFile", files, String.class);
|
|
|
|
+ return responseEntity.getStatusCode().equals(HttpStatus.OK);
|
|
|
|
+ }
|
|
}
|
|
}
|