|
@@ -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);
|