|
@@ -7,20 +7,21 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.app.service.impl;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
+import cn.com.qmth.examcloud.app.core.SysProperty;
|
|
|
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.HttpUtils;
|
|
|
+import cn.com.qmth.examcloud.app.model.Constants;
|
|
|
+import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
|
|
|
+import cn.com.qmth.examcloud.app.model.Result;
|
|
|
+import cn.com.qmth.examcloud.app.service.CoreOeService;
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonMapper;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.enums.ExamProperties;
|
|
|
-import cn.com.qmth.examcloud.app.model.Constants;
|
|
|
-import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
|
|
|
-import cn.com.qmth.examcloud.app.model.Result;
|
|
|
-import cn.com.qmth.examcloud.app.service.CoreOeService;
|
|
|
-import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
-import cn.com.qmth.examcloud.app.core.SysProperty;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import okhttp3.FormBody;
|
|
|
import okhttp3.FormBody.Builder;
|
|
|
import okhttp3.MediaType;
|
|
@@ -35,8 +36,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -50,7 +49,9 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Service
|
|
|
public class CoreOeServiceImpl implements CoreOeService {
|
|
|
+
|
|
|
private static final Logger log = LoggerFactory.getLogger(CoreOeServiceImpl.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private SysProperty sysProperty;
|
|
|
|
|
@@ -86,8 +87,8 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
Assert.notNull(fileName, "ExamRecordId must not be null.");
|
|
|
String fileType = FilenameUtils.getExtension(fileName.toLowerCase());
|
|
|
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)) {
|
|
|
+ && !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) {
|
|
@@ -125,16 +126,25 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result getAdminExamPaperStructList(String key, String token, String examRecordId,String fromCache) throws Exception {
|
|
|
+ public Result switchScreen(String key, String token, String examRecordDataId) throws Exception {
|
|
|
+ //封装请求参数
|
|
|
+ final String requestUrl = String.format("%s/api/ecs_oe_student/examControl/switchScreen?examRecordDataId=%s", sysProperty.getApiDomain(), examRecordDataId);
|
|
|
+ RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), "");
|
|
|
+ return HttpUtils.doPost(requestUrl, formBody, key, token);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getAdminExamPaperStructList(String key, String token, String examRecordId, String fromCache) throws Exception {
|
|
|
//封装请求参数
|
|
|
- String requestUrl=null;
|
|
|
- if("1".equals(fromCache)) {
|
|
|
+ String requestUrl = null;
|
|
|
+ if ("1".equals(fromCache)) {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct?fromCache=1&examRecordDataId=%s", sysProperty.getApiDomain(), examRecordId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=%s", sysProperty.getApiDomain(), examRecordId);
|
|
|
}
|
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public Result getStudentExamPaperStructList(String key, String token, String examRecordId) throws Exception {
|
|
|
//封装请求参数
|
|
@@ -157,7 +167,7 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result updateExamRecordPaperQuestionAnswer(String key, String token, Integer order, String studentAnswer,String audioPlayTimes) throws Exception {
|
|
|
+ public Result updateExamRecordPaperQuestionAnswer(String key, String token, Integer order, String studentAnswer, String audioPlayTimes) throws Exception {
|
|
|
//封装请求参数
|
|
|
final String requestUrl = String.format("%s/api/ecs_oe_student/examQuestion/submitQuestionAnswer", sysProperty.getApiDomain());
|
|
|
List<Map> paramsList = new ArrayList<Map>();
|
|
@@ -168,10 +178,10 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
paramsList.add(params);
|
|
|
String json = new JsonMapper().toJson(paramsList);
|
|
|
RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
|
|
|
- Map<String,String> headers=new HashMap<>();
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("REFERER", "app-referer");
|
|
|
headers.put("USER-AGENT", "app-" + cn.com.qmth.examcloud.support.Constants.ELECTRON_EXAM_SHELL);
|
|
|
- return HttpUtils.doPost(requestUrl, formBody, key, token,headers);
|
|
|
+ return HttpUtils.doPost(requestUrl, formBody, key, token, headers);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -185,25 +195,25 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
public Result checkOnlineExamRecord(String key, String token) throws Exception {
|
|
|
//封装请求参数
|
|
|
final String requestUrl = String.format("%s/api/ecs_oe_student/examControl/checkExamInProgress", sysProperty.getApiDomain());
|
|
|
- Result<String> ret=HttpUtils.doGet(requestUrl, key, token);
|
|
|
- if(Constants.CODE_200.equals(ret.getCode())&&StringUtils.isNotBlank(ret.getData())) {
|
|
|
- JSONObject data=JSONObject.parseObject(ret.getData());
|
|
|
- if(Constants.COMMON_SUCCESS_CODE.equals(data.getString("code"))) {
|
|
|
- JSONObject bdata=data.getJSONObject("data");
|
|
|
- if(bdata!=null) {
|
|
|
- Long examId=bdata.getLong("examId");
|
|
|
- if(examId!=null) {
|
|
|
- ExamSettingsCacheBean exam=CacheHelper.getExamSettings(examId);
|
|
|
- if(ExamType.ONLINE.name().equals(exam.getExamType())) {
|
|
|
- ExamPropertyCacheBean es=CacheHelper.getExamProperty(examId, ExamProperties.APP_EXAM_ENABLED.name());
|
|
|
- if(!"true".equals(es.getValue())) {
|
|
|
- ret.setCode(Constants.CODE_409);
|
|
|
- ret.setDesc(Constants.DESC_409);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ Result<String> ret = HttpUtils.doGet(requestUrl, key, token);
|
|
|
+ if (Constants.CODE_200.equals(ret.getCode()) && StringUtils.isNotBlank(ret.getData())) {
|
|
|
+ JSONObject data = JSONObject.parseObject(ret.getData());
|
|
|
+ if (Constants.COMMON_SUCCESS_CODE.equals(data.getString("code"))) {
|
|
|
+ JSONObject bdata = data.getJSONObject("data");
|
|
|
+ if (bdata != null) {
|
|
|
+ Long examId = bdata.getLong("examId");
|
|
|
+ if (examId != null) {
|
|
|
+ ExamSettingsCacheBean exam = CacheHelper.getExamSettings(examId);
|
|
|
+ if (ExamType.ONLINE.name().equals(exam.getExamType())) {
|
|
|
+ ExamPropertyCacheBean es = CacheHelper.getExamProperty(examId, ExamProperties.APP_EXAM_ENABLED.name());
|
|
|
+ if (!"true".equals(es.getValue())) {
|
|
|
+ ret.setCode(Constants.CODE_409);
|
|
|
+ ret.setDesc(Constants.DESC_409);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
@@ -216,12 +226,12 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result getExamRecordTotalInfo(String key, String token, String examRecordId,String fromCache) throws Exception {
|
|
|
+ public Result getExamRecordTotalInfo(String key, String token, String examRecordId, String fromCache) throws Exception {
|
|
|
//封装请求参数
|
|
|
- String requestUrl=null;
|
|
|
- if("1".equals(fromCache)) {
|
|
|
+ String requestUrl = null;
|
|
|
+ if ("1".equals(fromCache)) {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/practice/getPracticeDetailInfo?fromCache=1&examRecordDataId=%s", sysProperty.getApiDomain(), examRecordId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/practice/getPracticeDetailInfo?examRecordDataId=%s", sysProperty.getApiDomain(), examRecordId);
|
|
|
}
|
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
@@ -253,12 +263,12 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result findExamRecordDataEntity(String key, String token, Long examRecordDataId,String fromCache) throws Exception {
|
|
|
+ public Result findExamRecordDataEntity(String key, String token, Long examRecordDataId, String fromCache) throws Exception {
|
|
|
//封装请求参数
|
|
|
- String requestUrl=null;
|
|
|
- if("1".equals(fromCache)) {
|
|
|
+ String requestUrl = null;
|
|
|
+ if ("1".equals(fromCache)) {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/record/data/findExamRecordDataEntity?fromCache=1&examRecordDataId=%s", sysProperty.getApiDomain(), examRecordDataId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/record/data/findExamRecordDataEntity?examRecordDataId=%s", sysProperty.getApiDomain(), examRecordDataId);
|
|
|
}
|
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
@@ -270,12 +280,12 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result getExamRecordQuestions(String key, String token, Long examRecordDataId,String fromCache) throws Exception {
|
|
|
+ public Result getExamRecordQuestions(String key, String token, Long examRecordDataId, String fromCache) throws Exception {
|
|
|
//封装请求参数
|
|
|
- String requestUrl=null;
|
|
|
- if("1".equals(fromCache)) {
|
|
|
+ String requestUrl = null;
|
|
|
+ if ("1".equals(fromCache)) {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?fromCache=1&examRecordDataId=%s", sysProperty.getApiDomain(), examRecordDataId);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
requestUrl = String.format("%s/api/branch_ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?examRecordDataId=%s", sysProperty.getApiDomain(), examRecordDataId);
|
|
|
}
|
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
@@ -287,34 +297,34 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result getExamPropertyFromCacheByStudentSession(String key, String token,Long examId,String keys) throws Exception {
|
|
|
+ public Result getExamPropertyFromCacheByStudentSession(String key, String token, Long examId, String keys) throws Exception {
|
|
|
//封装请求参数
|
|
|
- final String requestUrl = String.format("%s/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/"+examId+"/"+keys, sysProperty.getApiDomain());
|
|
|
+ final String requestUrl = String.format("%s/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/" + examId + "/" + keys, sysProperty.getApiDomain());
|
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Result getPaperById(String key, String token, String paperId) throws Exception {
|
|
|
- final String requestUrl = String.format("%s/api/branch_ecs_ques/paper/"+paperId, sysProperty.getApiDomain());
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_ques/paper/" + paperId, sysProperty.getApiDomain());
|
|
|
Result<String> result = HttpUtils.doGet(requestUrl, key, token);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result getYunSignature(String key, String token, GetYunSignatureReq req) throws Exception {
|
|
|
//封装请求参数
|
|
|
final String requestUrl = String.format("%s/api/ecs_oe_student/examControl/yunSignature", sysProperty.getApiDomain());
|
|
|
- Builder b= new FormBody.Builder()
|
|
|
+ Builder b = new FormBody.Builder()
|
|
|
.add("examRecordDataId", req.getExamRecordDataId())
|
|
|
.add("order", req.getOrder())
|
|
|
.add("fileMd5", req.getFileMd5())
|
|
|
.add("fileSuffix", req.getFileSuffix());
|
|
|
- if(StringUtils.isNotBlank(req.getExt())) {
|
|
|
- b.add("ext", req.getExt());
|
|
|
+ if (StringUtils.isNotBlank(req.getExt())) {
|
|
|
+ b.add("ext", req.getExt());
|
|
|
}
|
|
|
- RequestBody formBody =b.build();
|
|
|
-
|
|
|
+ RequestBody formBody = b.build();
|
|
|
+
|
|
|
return HttpUtils.doPost(requestUrl, formBody, key, token);
|
|
|
}
|
|
|
|
|
@@ -326,46 +336,46 @@ public class CoreOeServiceImpl implements CoreOeService {
|
|
|
|
|
|
@Override
|
|
|
public Result getEndExamInfo(String key, String token, Long examRecordDataId) throws Exception {
|
|
|
- final String requestUrl = String.format("%s/api/ecs_oe_student/examControl/getEndExamInfo?examRecordDataId="+examRecordDataId, sysProperty.getApiDomain());
|
|
|
+ final String requestUrl = String.format("%s/api/ecs_oe_student/examControl/getEndExamInfo?examRecordDataId=" + examRecordDataId, sysProperty.getApiDomain());
|
|
|
return HttpUtils.doGet(requestUrl, key, token);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Result queryObjectiveScoreList(String key, String token, Long examStudentId) throws Exception {
|
|
|
- final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/score/queryObjectiveScoreList?examStudentId="+examStudentId, sysProperty.getApiDomain());
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/exam/score/queryObjectiveScoreList?examStudentId=" + examStudentId, sysProperty.getApiDomain());
|
|
|
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.getApiDomain());
|
|
|
- RequestBody formBody = new FormBody.Builder()
|
|
|
+ @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.getApiDomain());
|
|
|
+ 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 {
|
|
|
+ @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)) {
|
|
|
+ && !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.getApiDomain());
|
|
|
+ final String requestUrl = String.format("%s/api/branch_ecs_oe_admin/offlineExam/batchSubmitPaper?examRecordDataId=" + examRecordDataId + "&fileType=" + fileType, sysProperty.getApiDomain());
|
|
|
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);
|
|
|
+ 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 : "");
|
|
|
+ for (String md5 : fileMd5Array) {
|
|
|
+ form.addFormDataPart("fileMd5Array", md5 != null ? md5 : "");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return HttpUtils.doPost(requestUrl, form.build(), key, token);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
}
|