|
@@ -1,18 +1,7 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.transaction.Transactional;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
@@ -23,11 +12,7 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordForMarkingEntity
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamStudentEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExamProperties;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExamRecordStatus;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordDataService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.OfflineExamService;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.OfflineExamCourseInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordDataBean;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamStudentBean;
|
|
@@ -37,13 +22,20 @@ import cn.com.qmth.examcloud.core.questions.api.request.GetPaperReq;
|
|
|
import cn.com.qmth.examcloud.core.questions.api.response.GetPaperResp;
|
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.ExamOrgSettingsCacheBean;
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.ExamPropertyCacheBean;
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.ExamStudentSettingsCacheBean;
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.*;
|
|
|
+import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
|
|
|
+import cn.com.qmth.examcloud.web.filestorage.FileStorageUtil;
|
|
|
+import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
-import main.java.com.UpYun;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.transaction.Transactional;
|
|
|
+import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @author chenken
|
|
@@ -78,27 +70,15 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
@Autowired
|
|
|
private ExamRecordForMarkingRepo examRecordForMarkingRepo;
|
|
|
|
|
|
- @Value("${$upyun.site.1.bucketName}")
|
|
|
- private String bucketName;
|
|
|
-
|
|
|
- @Value("${$upyun.site.1.userName}")
|
|
|
- private String userName;
|
|
|
-
|
|
|
- @Value("${$upyun.site.1.password}")
|
|
|
- private String password;
|
|
|
-
|
|
|
@Value("${app.upyun.uploadUrl}")
|
|
|
private String upyunUploadUrl;
|
|
|
|
|
|
- @Value("${$upyun.site.1.domain}")
|
|
|
- private String upyunFileUrl;
|
|
|
-
|
|
|
@Override
|
|
|
public List<OfflineExamCourseInfo> getOfflineCourse(Long studentId) {
|
|
|
List<ExamStudentEntity> examStudents = examStudentRepo.findByStudentId(studentId);
|
|
|
- List<OfflineExamCourseInfo> offlineExamCourseInfoList = new ArrayList<OfflineExamCourseInfo>();
|
|
|
+ List<OfflineExamCourseInfo> offlineExamCourseInfoList = new ArrayList<>();
|
|
|
for (ExamStudentEntity examStudent : examStudents) {
|
|
|
- ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(),studentId);
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudent.getExamId(), studentId);
|
|
|
if (!ExamType.OFFLINE.name().equals(examBean.getExamType())) {
|
|
|
continue;
|
|
|
}
|
|
@@ -157,9 +137,9 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
@Override
|
|
|
public void startOfflineExam(Long examStudentId) {
|
|
|
SysPropertyCacheBean stuClientLoginLimit = CacheHelper.getSysProperty("STU_CLIENT_LOGIN_LIMIT");
|
|
|
- Boolean stuClientLoginLimitBoolean = false;
|
|
|
+ boolean stuClientLoginLimitBoolean = false;
|
|
|
if (stuClientLoginLimit.getHasValue()) {
|
|
|
- stuClientLoginLimitBoolean = Boolean.valueOf(stuClientLoginLimit.getValue().toString());
|
|
|
+ stuClientLoginLimitBoolean = Boolean.parseBoolean(stuClientLoginLimit.getValue().toString());
|
|
|
}
|
|
|
if (stuClientLoginLimitBoolean) {
|
|
|
throw new StatusException("1001", "系统维护中... ...");
|
|
@@ -170,7 +150,7 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
}
|
|
|
//获取考生信息
|
|
|
ExamStudentEntity examStudentEntity = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
- ExamStudentBean bean=of(examStudentEntity);
|
|
|
+ ExamStudentBean bean = of(examStudentEntity);
|
|
|
//检查并获取课程信息
|
|
|
CourseBean courseBean = checkCourse(bean);
|
|
|
//检查并获取考试信息
|
|
@@ -257,20 +237,25 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
if (examRecordDataEntity == null) {
|
|
|
return;
|
|
|
}
|
|
|
- ExamRecordDataBean bean=of(examRecordDataEntity);
|
|
|
+ ExamRecordDataBean bean = of(examRecordDataEntity);
|
|
|
String fileName = tempFile.getName();
|
|
|
String fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()).toLowerCase();
|
|
|
- //上传文件至又拍云
|
|
|
- String fileNewName = createOfflineFileName(bean) + "." + fileSuffix;
|
|
|
|
|
|
+ //上传文件至又拍云
|
|
|
ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
- String upyunFilePath = upyunUploadUrl + examRecordData.getExamId() + "/" + fileNewName;
|
|
|
- UpYun upyun = new UpYun(bucketName, userName, password);
|
|
|
- upyun.writeFile(upyunFilePath, tempFile, true);
|
|
|
+ String fileNewName = createOfflineFileName(bean) + "." + fileSuffix;
|
|
|
+ String relativePath = upyunUploadUrl + examRecordData.getExamId() + "/" + fileNewName;
|
|
|
+
|
|
|
+ //通用存储
|
|
|
+ FileStoragePathEnvInfo env = new FileStoragePathEnvInfo();
|
|
|
+ env.setFileSuffix(fileSuffix);
|
|
|
+ env.setRootOrgId(String.valueOf(bean.getRootOrgId()));
|
|
|
+ env.setRelativePath(relativePath);
|
|
|
+ YunPathInfo pi = FileStorageUtil.saveFile("offlineFile", env, tempFile, null);
|
|
|
tempFile.delete();
|
|
|
- //保存 文件信息
|
|
|
- String fileUrl = upyunFileUrl + upyunFilePath;
|
|
|
- examRecordForMarkingService.saveOffLineExamRecordForMarking(bean, fileNewName, fileUrl);
|
|
|
+
|
|
|
+ examRecordForMarkingService.saveOffLineExamRecordForMarking(bean, fileNewName, pi.getRelativePath());
|
|
|
+
|
|
|
//更新考试记录状态
|
|
|
examRecordDataEntity.setExamRecordStatus(ExamRecordStatus.EXAM_END);
|
|
|
examRecordDataEntity.setEndTime(new Date());//交卷(上传)时间
|
|
@@ -278,7 +263,6 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private String createOfflineFileName(ExamRecordDataBean examRecordData) {
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
@@ -287,8 +271,8 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
long courseId = examRecordData.getCourseId();
|
|
|
CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(courseId);
|
|
|
return orgBean.getCode() + "_" +
|
|
|
- examRecordData.getStudentCode() + "_" +
|
|
|
- examRecordData.getStudentName() + "_" +
|
|
|
+ examRecordData.getStudentCode() + "_" +
|
|
|
+ examRecordData.getStudentName() + "_" +
|
|
|
courseBean.getCode() + "_" + currentTime;
|
|
|
}
|
|
|
|
|
@@ -304,10 +288,10 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
info.setStudentName(record.getStudentName());
|
|
|
info.setIdentityNumber(record.getIdentityNumber());
|
|
|
info.setCourseId(record.getCourseId());
|
|
|
-
|
|
|
+
|
|
|
info.setCourseLevel(record.getCourseLevel());
|
|
|
info.setOrgId(record.getOrgId());
|
|
|
-
|
|
|
+
|
|
|
info.setRootOrgId(record.getRootOrgId());
|
|
|
info.setBasePaperId(record.getBasePaperId());
|
|
|
info.setPaperStructId(record.getPaperStructId());
|
|
@@ -338,9 +322,9 @@ public class OfflineExamServiceImpl implements OfflineExamService {
|
|
|
info.setFaceLandmarkVal(record.getFaceLandmarkVal());
|
|
|
return info;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private ExamStudentBean of(ExamStudentEntity et) {
|
|
|
- ExamStudentBean b=new ExamStudentBean();
|
|
|
+ ExamStudentBean b = new ExamStudentBean();
|
|
|
b.setId(et.getId());
|
|
|
b.setExamStudentId(et.getExamStudentId());
|
|
|
b.setExamId(et.getExamId());
|