|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.mooctest.dao.MasterReportDao;
|
|
|
import com.mooctest.dao.TaskDao;
|
|
|
import com.mooctest.dao2.CrowdTaskDao;
|
|
|
+import com.mooctest.data.SimpleResponse;
|
|
|
import com.mooctest.data.TaskDTO;
|
|
|
import com.mooctest.model.CrowdTask;
|
|
|
import com.mooctest.model.Task;
|
|
@@ -264,30 +265,27 @@ public class TaskService {
|
|
|
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":"创建失败";
|
|
|
+ long flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),"",getMaxCaseId()+1,type,description,name);
|
|
|
+ return flag!=-1 ?""+flag:"创建失败";
|
|
|
} 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){
|
|
|
- if (requirement==null||requirement.isEmpty()) return "请提交需求文档";
|
|
|
- if(threePage ==null || threePage.isEmpty()) return "请提交三级页面";
|
|
|
- if(type.equals(TaskUtil.TaskType.MOBILE.getTaskType())&&(apk==null ||apk.isEmpty()))return "请提交APK文件";
|
|
|
+ public SimpleResponse addCrowdTask(String name, String description, String time, String type, String os, MultipartFile threePage){
|
|
|
+ if(threePage ==null || threePage.isEmpty()) return new SimpleResponse(400,"请提交三级页面");
|
|
|
String threePageUrl = fileService.uploadFile(threePage);
|
|
|
- String requirementUrl = fileService.uploadFile(requirement);
|
|
|
try {
|
|
|
- boolean flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),"",getMaxCaseId()+1,type,description,name);
|
|
|
- return flag ?"success":"创建失败";
|
|
|
+ long flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),generatePaperType(type,os),getMaxCaseId()+1,type,description,name);
|
|
|
+ return flag!=-1 ?new SimpleResponse(200,"创建成功,id为"+flag):new SimpleResponse(400,"创建失败");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- return "创建众测失败";
|
|
|
+ return new SimpleResponse(400,"创建众测失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public boolean createCrowdTest(String file, String fileName, String paperType, Long caseId, String testType, String description, String appName) throws Exception {
|
|
|
+ public long createCrowdTest(String file, String fileName, String paperType, Long caseId, String testType, String description, String appName) throws Exception {
|
|
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
params.add("file", file);
|
|
|
params.add("file_name", fileName);
|
|
@@ -302,8 +300,8 @@ public class TaskService {
|
|
|
("http://" + reportHost + "/Bug/api/extra/uploadExamUrl", params, String.class);
|
|
|
if (responseEntity.getStatusCode().equals(HttpStatus.OK)){
|
|
|
fileService.uploadJson(responseEntity.getBody(),caseId);
|
|
|
- return true;
|
|
|
- }else return false;
|
|
|
+ return caseId;
|
|
|
+ }else return -1;
|
|
|
}
|
|
|
|
|
|
public String getEncodeTaskReportUrl(long examId,long caseId){
|
|
@@ -391,4 +389,30 @@ public class TaskService {
|
|
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity("http://" + reportHost + "/Bug/api/data/inputFromFile", files, String.class);
|
|
|
return responseEntity.getStatusCode().equals(HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private static String generatePaperType(String testType , String os){
|
|
|
+ String defaultValue = "\"windows\",\"linux\",\"macos\"";
|
|
|
+ StringBuffer value = new StringBuffer();
|
|
|
+ if(os==null||os.length()==0){
|
|
|
+ if(testType.equals(TaskUtil.TaskType.MOBILE.getTaskType())){
|
|
|
+ value.append("\"Android\",\"ios\"");
|
|
|
+ }else{
|
|
|
+ value.append("\"windows\",\"linux\",\"macos\"");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ String [] data = os.split(";");
|
|
|
+ for(int i =0;i<data.length;i++){
|
|
|
+ if(i!=data.length-1){
|
|
|
+ value.append("\""+data[i]+"\",");
|
|
|
+ }else{
|
|
|
+ value.append("\""+data[i]+"\"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "{\"title\":\"测试报告名称\",\"subTitles\":[{\"name\":\"设备名称\", \"type\":\"text\"},{\"name\":\"设备品牌\",\"type\":\"text\"},{\"name\":\"操作系统\",\"type\":\"enum\",\"value\":["
|
|
|
+ +value.toString()
|
|
|
+ + "]}],\"caseList\":true,\"bugList\": true,\"testScript\":false,\"suppleReport\":false,\"testLog\":false}";
|
|
|
+ }
|
|
|
}
|