|
@@ -10,7 +10,7 @@ package cn.com.qmth.examcloud.app.service.impl;
|
|
import cn.com.qmth.examcloud.app.core.exception.ApiException;
|
|
import cn.com.qmth.examcloud.app.core.exception.ApiException;
|
|
import cn.com.qmth.examcloud.app.core.utils.DateUtils;
|
|
import cn.com.qmth.examcloud.app.core.utils.DateUtils;
|
|
import cn.com.qmth.examcloud.app.core.utils.HttpUtils;
|
|
import cn.com.qmth.examcloud.app.core.utils.HttpUtils;
|
|
-import cn.com.qmth.examcloud.app.core.utils.JsonMapper;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.util.JsonMapper;
|
|
import cn.com.qmth.examcloud.app.model.Constants;
|
|
import cn.com.qmth.examcloud.app.model.Constants;
|
|
import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
|
|
import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
@@ -28,15 +28,13 @@ import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
-import static cn.com.qmth.examcloud.app.model.Constants.FILE_TYPE_PDF;
|
|
|
|
-import static cn.com.qmth.examcloud.app.model.Constants.FILE_TYPE_ZIP;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 网考业务服务接口
|
|
* 网考业务服务接口
|
|
*
|
|
*
|
|
@@ -64,14 +62,14 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
@Override
|
|
@Override
|
|
public Result getOfflineExamCourseList(String key, String token) throws Exception {
|
|
public Result getOfflineExamCourseList(String key, String token) throws Exception {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/offlineExam/getOfflineCourse", sysProperty.getCoreOeAdminUrl());
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/offlineExam/getOfflineCourse", sysProperty.getCoreOeAdminUrl());
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result startOfflineExamRecord(String key, String token, String examStudentId) throws Exception {
|
|
public Result startOfflineExamRecord(String key, String token, String examStudentId) throws Exception {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/offlineExam/startOfflineExam?examStudentId=%s", sysProperty.getCoreOeAdminUrl(), examStudentId);
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/offlineExam/startOfflineExam?examStudentId=%s", sysProperty.getCoreOeAdminUrl(), examStudentId);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -80,14 +78,16 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
Assert.notNull(examRecordId, "FileName must not be null.");
|
|
Assert.notNull(examRecordId, "FileName must not be null.");
|
|
Assert.notNull(fileName, "ExamRecordId must not be null.");
|
|
Assert.notNull(fileName, "ExamRecordId must not be null.");
|
|
String fileType = FilenameUtils.getExtension(fileName.toLowerCase());
|
|
String fileType = FilenameUtils.getExtension(fileName.toLowerCase());
|
|
- if (!FILE_TYPE_ZIP.equals(fileType) && !FILE_TYPE_PDF.equals(fileType)) {
|
|
|
|
- throw new ApiException("FileType must be zip or pdf.");
|
|
|
|
|
|
+ if (!Constants.FILE_TYPE_ZIP.equals(fileType) && !Constants.FILE_TYPE_PDF.equals(fileType)
|
|
|
|
+ && !Constants.FILE_TYPE_JPG.equals(fileType)&& !Constants.FILE_TYPE_JPEG.equals(fileType)
|
|
|
|
+ && !Constants.FILE_TYPE_PNG.equals(fileType)) {
|
|
|
|
+ throw new ApiException("FileType must be zip,pdf,jpg,jpeg,png.");
|
|
}
|
|
}
|
|
if (fileBytes.length == 0) {
|
|
if (fileBytes.length == 0) {
|
|
throw new ApiException("File must be not empty.");
|
|
throw new ApiException("File must be not empty.");
|
|
}
|
|
}
|
|
//封装请求参数
|
|
//封装请求参数
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/offlineExam/submitPaper?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/offlineExam/submitPaper?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
MultipartBody.Builder form = new MultipartBody.Builder().setType(MultipartBody.FORM);
|
|
MultipartBody.Builder form = new MultipartBody.Builder().setType(MultipartBody.FORM);
|
|
RequestBody body = RequestBody.create(MediaType.parse("application/octet-stream"), fileBytes);
|
|
RequestBody body = RequestBody.create(MediaType.parse("application/octet-stream"), fileBytes);
|
|
form.addFormDataPart("file", fileName, body);
|
|
form.addFormDataPart("file", fileName, body);
|
|
@@ -99,7 +99,7 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
@Override
|
|
@Override
|
|
public Result getPracticeExamCourseList(String key, String token, String examId) throws Exception {
|
|
public Result getPracticeExamCourseList(String key, String token, String examId) throws Exception {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/practice/queryPracticeCourseList?examId=%s", sysProperty.getCoreOeAdminUrl(), examId);
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/practice/queryPracticeCourseList?examId=%s", sysProperty.getCoreOeAdminUrl(), examId);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -122,9 +122,9 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
String requestUrl=null;
|
|
String requestUrl=null;
|
|
if("1".equals(fromCache)) {
|
|
if("1".equals(fromCache)) {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
}else {
|
|
}else {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
}
|
|
}
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
@@ -181,7 +181,7 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
@Override
|
|
@Override
|
|
public Result getExamRecordPracticeHistoryList(String key, String token, String examStudentId) throws Exception {
|
|
public Result getExamRecordPracticeHistoryList(String key, String token, String examStudentId) throws Exception {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/practice/queryPracticeRecordList?examStudentId=%s", sysProperty.getCoreOeAdminUrl(), examStudentId);
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/practice/queryPracticeRecordList?examStudentId=%s", sysProperty.getCoreOeAdminUrl(), examStudentId);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -190,9 +190,9 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
String requestUrl=null;
|
|
String requestUrl=null;
|
|
if("1".equals(fromCache)) {
|
|
if("1".equals(fromCache)) {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/practice/getPracticeDetailInfo?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/practice/getPracticeDetailInfo?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
}else {
|
|
}else {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/practice/getPracticeDetailInfo?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/practice/getPracticeDetailInfo?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordId);
|
|
}
|
|
}
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
@@ -227,9 +227,9 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
String requestUrl=null;
|
|
String requestUrl=null;
|
|
if("1".equals(fromCache)) {
|
|
if("1".equals(fromCache)) {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/exam/record/data/findExamRecordDataEntity?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/record/data/findExamRecordDataEntity?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
}else {
|
|
}else {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/exam/record/data/findExamRecordDataEntity?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/record/data/findExamRecordDataEntity?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
}
|
|
}
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
if (result.isSuccess()) {
|
|
if (result.isSuccess()) {
|
|
@@ -244,9 +244,9 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
//封装请求参数
|
|
//封装请求参数
|
|
String requestUrl=null;
|
|
String requestUrl=null;
|
|
if("1".equals(fromCache)) {
|
|
if("1".equals(fromCache)) {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?fromCache=1&examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
}else {
|
|
}else {
|
|
- requestUrl = String.format("%s/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
|
|
|
|
+ requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?examRecordDataId=%s", sysProperty.getCoreOeAdminUrl(), examRecordDataId);
|
|
}
|
|
}
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
if (result.isSuccess()) {
|
|
if (result.isSuccess()) {
|
|
@@ -266,7 +266,7 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result getPaperById(String key, String token, String paperId) throws Exception {
|
|
public Result getPaperById(String key, String token, String paperId) throws Exception {
|
|
- final String requestUrl = String.format("%s/api/ecs_ques/paper/"+paperId, sysProperty.getCoreQuestionUrl());
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_ques/paper/"+paperId, sysProperty.getCoreQuestionUrl());
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -290,7 +290,7 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result queryExamList(String key, String token) throws Exception {
|
|
public Result queryExamList(String key, String token) throws Exception {
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/examControl/queryExamList", sysProperty.getCoreOeAdminUrl());
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/examControl/queryExamList", sysProperty.getCoreOeAdminUrl());
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -302,8 +302,40 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result queryObjectiveScoreList(String key, String token, Long examStudentId) throws Exception {
|
|
public Result queryObjectiveScoreList(String key, String token, Long examStudentId) throws Exception {
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_admin/exam/score/queryObjectiveScoreList?examStudentId="+examStudentId, sysProperty.getCoreOeAdminUrl());
|
|
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/score/queryObjectiveScoreList?examStudentId="+examStudentId, sysProperty.getCoreOeAdminUrl());
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result startAnswer(String key, String token, Long examRecordDataId) throws Exception {
|
|
|
|
+ final String requestUrl = String.format("%s/api/ecs_oe_student/examControl/startAnswer", sysProperty.getCoreOeStudentUrl());
|
|
|
|
+ RequestBody formBody = new FormBody.Builder()
|
|
|
|
+ .add("examRecordDataId", examRecordDataId.toString())
|
|
|
|
+ .build();
|
|
|
|
+ return HttpUtils.doPost(requestUrl, formBody, key, token);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result uploadPaperAnswerBatch(String key, String token, Long examRecordDataId, MultipartFile[] fileArray,
|
|
|
|
+ String fileType, String[] fileMd5Array) throws Exception {
|
|
|
|
+ if (!Constants.FILE_TYPE_ZIP.equals(fileType) && !Constants.FILE_TYPE_PDF.equals(fileType)
|
|
|
|
+ && !Constants.FILE_TYPE_JPG.equals(fileType)&& !Constants.FILE_TYPE_JPEG.equals(fileType)
|
|
|
|
+ && !Constants.FILE_TYPE_PNG.equals(fileType)) {
|
|
|
|
+ throw new ApiException("FileType must be zip,pdf,jpg,jpeg,png.");
|
|
|
|
+ }
|
|
|
|
+ //封装请求参数
|
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/offlineExam/batchSubmitPaper?examRecordDataId="+examRecordDataId+"&fileType="+fileType, sysProperty.getCoreOeAdminUrl());
|
|
|
|
+ MultipartBody.Builder form = new MultipartBody.Builder().setType(MultipartBody.FORM);
|
|
|
|
+ for(MultipartFile file:fileArray) {
|
|
|
|
+ RequestBody body = RequestBody.create(MediaType.parse("application/octet-stream"), file.getBytes());
|
|
|
|
+ form.addFormDataPart("fileArray", file.getOriginalFilename(), body);
|
|
|
|
+ }
|
|
|
|
+ form.addFormDataPart("fileType", fileType);
|
|
|
|
+ for(String md5:fileMd5Array) {
|
|
|
|
+ form.addFormDataPart("fileMd5Array", md5 != null ? md5 : "");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return HttpUtils.doPost(requestUrl, form.build(), key, token);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|