wangwei пре 5 година
родитељ
комит
39634b5431

+ 26 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamStudentCloudServiceProvider.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.examwork.api.provider;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
 import com.google.common.collect.Lists;
 
 import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.util.BooleanUtil;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
 import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
 import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
@@ -41,7 +43,9 @@ import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
 import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudentEntity;
+import cn.com.qmth.examcloud.core.examwork.service.ExamService;
 import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamSpecialSettingsInfo;
 import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
 import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
 import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
@@ -80,6 +84,9 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 	@Autowired
 	ExamRepo examRepo;
 
+	@Autowired
+	ExamService examService;
+
 	@Autowired
 	OrgCloudService orgCloudService;
 
@@ -107,6 +114,7 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 	@Override
 	public SaveExamStudentResp saveExamStudent(@RequestBody SaveExamStudentReq req) {
 		trim(req);
+
 		ExamStudentInfo info = new ExamStudentInfo();
 		info.setCourseCode(req.getCourseCode());
 		info.setCourseName(req.getCourseName());
@@ -133,6 +141,24 @@ public class ExamStudentCloudServiceProvider extends ControllerSupport
 
 		ExamStudentInfo saved = examStudentService.saveExamStudent(info);
 
+		Date specialBeginTime = req.getSpecialBeginTime();
+		Date specialEndTime = req.getSpecialEndTime();
+
+		if (!new Boolean(null == specialBeginTime).equals(new Boolean(null == specialEndTime))) {
+			throw new StatusException("210101", "specialBeginTime & specialEndTime  wrong");
+		}
+
+		if (2 == BooleanUtil.countTrue(null != specialBeginTime, null != specialEndTime)) {
+			ExamSpecialSettingsInfo examSpecialInfo = new ExamSpecialSettingsInfo();
+			examSpecialInfo.setBeginTime(specialBeginTime);
+			examSpecialInfo.setEndTime(specialEndTime);
+			examSpecialInfo.setExamId(req.getExamId());
+			examSpecialInfo.setExamLimit(false);
+			examSpecialInfo.setRootOrgId(req.getRootOrgId());
+			examSpecialInfo.setStudentId(saved.getStudentId());
+			examService.saveExamSpecialSettings(examSpecialInfo);
+		}
+
 		SaveExamStudentResp resp = new SaveExamStudentResp();
 
 		ExamStudentBean examStudentBean = new ExamStudentBean();