浏览代码

新增信创调用创建任务接口,修改使用线上mongo

郭超 4 年之前
父节点
当前提交
c427015c73

+ 1 - 1
src/main/java/com/mooctest/CrowdReviewApplication.java

@@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
 public class CrowdReviewApplication extends SpringBootServletInitializer {
     public static void main(String[] args) {
         String relativelyPath = System.getProperty("user.dir");
-        System.out.println(relativelyPath);
+//        System.out.println(relativelyPath);
         // 1. 创建生成文档的配置
         DocsConfig config= new DocsConfig();
         // 项目根目录

+ 14 - 5
src/main/java/com/mooctest/controller/TaskController.java

@@ -213,27 +213,36 @@ public class TaskController {
         return taskService.addCrowdTask(name, description, os, threePage);
     }
 
+    /**
+     * 信创创建任务后调用此接口在众测新建任务 /addCrowdTaskDefault
+     * collaborativeType 0-非协作 1-协作
+     * @param name
+     * @param description
+     * @param collaborativeType
+     * @return
+     */
     @PostMapping("/addCrowdTaskDefault")
     @ResponseBody
-    public SimpleResponse addCrowdTaskDefault(@RequestParam("name")String name, @RequestParam("description")String description,
-                                        @RequestParam("threePage") MultipartFile threePage){
+    public SimpleResponse addCrowdTaskDefault(@RequestParam("name")String name, @RequestParam("description")String description,@RequestParam("collaborativeType")int collaborativeType,
+                                              @RequestParam("threePageUrl") String threePageUrl, @RequestParam("fileName") String fileName){
         Map<String, String> configurationMap = configurationService.getConfigurationMap();
         String os = configurationMap.get("os");
         // 后边generatePaperType方法中会根据;进行split
         os = os.replaceAll(",", ";");
 
-        if(threePage ==null || threePage.isEmpty()) {
+        if(threePageUrl == null || threePageUrl.equals("")) {
             return new SimpleResponse(400,"请提交三级页面");
         }
-        long caseId = taskService.addCrowdTaskDefault(name, description, os, threePage);
+        long caseId = taskService.addCrowdTaskDefault(name, description, os, threePageUrl, fileName, collaborativeType);
         long examId = caseId;
         // 返回服务序列号
         String encodedUrl = taskService.getEncodeTaskReportUrl(examId, caseId);
+        String writeReportUrl = taskService.getTaskReportUrl(examId, caseId);
         encodedUrl = encodedUrl.replaceAll("%3D", "=");
         // 返回大图url
         String taskDaPanUrl = taskService.getTaskDaPanUrl(examId, caseId);
         taskDaPanUrl = taskDaPanUrl.replaceAll("%3D", "=");
-        TaskExtend taskExtend = new TaskExtend(examId, caseId, encodedUrl, taskDaPanUrl);
+        TaskExtend taskExtend = new TaskExtend(examId, caseId, encodedUrl, writeReportUrl, taskDaPanUrl);
         return caseId != -1 ? new SimpleResponse(200,"创建成功", taskExtend) : new SimpleResponse(400,"创建失败");
     }
 }

+ 26 - 0
src/main/java/com/mooctest/data/enums/CollaborativeType.java

@@ -0,0 +1,26 @@
+package com.mooctest.data.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author guochao
+ * @date 2021-05-13 14:31
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+public enum CollaborativeType {
+	IS_COLLABORATIVE(0, "isCollaborative"),
+	IS_NOT_COLLABORATIVE(1, "isNotCollaborative");
+
+	private int id;
+	private String name;
+
+	public int getId() {
+		return id;
+	}
+
+	public String getName() {
+		return name;
+	}
+}

+ 1 - 0
src/main/java/com/mooctest/model/TaskExtend.java

@@ -13,5 +13,6 @@ public class TaskExtend {
     private long taskId;
     private long caseId;
     private String encodedUrl;
+    private String writeReportUrl;
     private String taskDaPanUrl;
 }

+ 13 - 12
src/main/java/com/mooctest/service/TaskService.java

@@ -8,13 +8,12 @@ import com.mooctest.dao.TaskDao;
 import com.mooctest.dao2.CrowdTaskDao;
 import com.mooctest.data.SimpleResponse;
 import com.mooctest.data.TaskDTO;
+import com.mooctest.data.enums.CollaborativeType;
 import com.mooctest.model.CrowdTask;
 import com.mooctest.model.Task;
 import com.mooctest.service.impl.ConfigurationService;
 import com.mooctest.util.EncodeUtil;
-import com.mooctest.util.TaskUtil;
 import com.mooctest.util.TimeUtil;
-import org.bson.Document;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -25,13 +24,9 @@ import org.springframework.http.converter.StringHttpMessageConverter;
 import org.springframework.stereotype.Service;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
-import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
@@ -270,7 +265,7 @@ public class TaskService {
         if(threePage ==null || threePage.isEmpty()) return "请提交三级页面";
         String threePageUrl = fileService.uploadFile(threePage);
         try {
-            long flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),"",getMaxCaseId()+1,type,description,name);
+            long flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),"",getMaxCaseId()+1,type,description,name, CollaborativeType.IS_COLLABORATIVE.getId());
             return flag!=-1 ?""+flag:"创建失败";
         } catch (Exception e) {
             e.printStackTrace();
@@ -282,7 +277,7 @@ public class TaskService {
         if(threePage ==null || threePage.isEmpty()) return new SimpleResponse(400,"请提交三级页面");
         String threePageUrl = fileService.uploadFile(threePage);
         try {
-            long flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),generatePaperType(os),getMaxCaseId()+1,"",description,name);
+            long flag = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),generatePaperType(os),getMaxCaseId()+1,"",description,name, CollaborativeType.IS_COLLABORATIVE.getId());
             return flag!=-1 ?new SimpleResponse(200,"创建成功,id为"+flag):new SimpleResponse(400,"创建失败");
         } catch (Exception e) {
             e.printStackTrace();
@@ -290,10 +285,11 @@ public class TaskService {
         }
     }
 
-    public long addCrowdTaskDefault(String name, String description, String os, MultipartFile threePage){
-        String threePageUrl = fileService.uploadFile(threePage);
+    public long addCrowdTaskDefault(String name, String description, String os, String threePageUrl, String fileName, int collaborativeType){
+        // 不进行上传是否存在问题
+//        String threePageUrl = fileService.uploadFile(threePage);
         try {
-            long caseId = createCrowdTest(threePageUrl,threePage.getOriginalFilename(),generatePaperType(os),getMaxCaseId()+1,"",description,name);
+            long caseId = createCrowdTest(threePageUrl,fileName,generatePaperType(os),getMaxCaseId()+1,"",description,name, collaborativeType);
             return caseId;
         } catch (Exception e) {
             e.printStackTrace();
@@ -301,7 +297,7 @@ public class TaskService {
         }
     }
 
-    public long 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, int collaborativeType) throws Exception {
         MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
         params.add("file", file);
         params.add("file_name", fileName);
@@ -310,6 +306,7 @@ public class TaskService {
         params.add("test_type", testType);
         params.add("description", description);
         params.add("app_name", appName);
+        params.add("collaborative_type", collaborativeType + "");
         RestTemplate restTemplate = new RestTemplate();
         restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
         ResponseEntity<String> responseEntity = restTemplate.postForEntity
@@ -329,6 +326,10 @@ public class TaskService {
         return encodedUrl;
     }
 
+    public String getTaskReportUrl(long examId,long caseId){
+        return HTTP + reportHost + "/report/detail/" + examId +"/" +caseId +"/userId";
+    }
+
     public TaskDTO getByExamIdAndCaseId(long examId, long caseId) {
         TaskDTO taskDefault = new TaskDTO();
         taskDefault.setExamId(examId);

+ 32 - 0
src/main/resources/apidoc/V1.0/apidoc.log.1

@@ -0,0 +1,32 @@
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: find java src paths:  [/Users/guochao/Desktop/project/moooc_review/src/test/java/]
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: project type not set, try to figure out...
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: found it a GENERIC project, tell us if we are wrong.
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: start find controllers in path : /Users/guochao/Desktop/project/moooc_review/src/test/java/
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate api docs start...
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate index start !!!
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate index done !!!
+五月 12, 2021 3:48:36 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate api docs done !!!
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: find java src paths:  [/Users/guochao/Desktop/project/moooc_review/src/test/java/]
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: project type not set, try to figure out...
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: found it a GENERIC project, tell us if we are wrong.
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: start find controllers in path : /Users/guochao/Desktop/project/moooc_review/src/test/java/
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate api docs start...
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate index start !!!
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate index done !!!
+五月 12, 2021 3:48:37 下午 io.github.yedaxia.apidocs.LogUtils info
+信息: info: generate api docs done !!!

+ 7 - 7
src/main/resources/application.yml

@@ -22,13 +22,13 @@ spring:
   thymeleaf:
     cache: false
 
-mongodb1.database: test
-mongodb1.host: 121.196.124.158
-mongodb1.port: 27017
-
-mongodb2.database: test
-mongodb2.host: 121.196.124.158
-mongodb2.port: 27017
+#mongodb1.database: test
+#mongodb1.host: 121.196.124.158
+#mongodb1.port: 27017
+#
+#mongodb2.database: test
+#mongodb2.host: 121.196.124.158
+#mongodb2.port: 27017
 
 report.export.addr: http://47.99.140.117:9002/generateReport
 report.export.excel.addr: http://47.99.140.117:9003/generateReport