|
@@ -13,6 +13,7 @@ import static cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.ExamS
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -25,14 +26,17 @@ import java.util.stream.Stream;
|
|
|
import javax.persistence.EntityManager;
|
|
|
import javax.persistence.Query;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.commons.util.DateUtil;
|
|
|
import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examstudent.*;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.cache.ExamStudentCache;
|
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
|
import cn.com.qmth.examcloud.examwork.api.request.GetExamStudentReq;
|
|
|
import cn.com.qmth.examcloud.examwork.api.response.GetExamStudentResp;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
|
|
|
+import cn.com.qmth.examcloud.support.enums.ExamProperties;
|
|
|
import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.hibernate.query.NativeQuery;
|
|
@@ -43,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -61,14 +66,8 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
|
|
|
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.CourseLevel;
|
|
|
-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.dao.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.FinishStatus;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamStudentService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.GainBaseDataService;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.LocalCacheService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.others.ExamCacheTransferHelper;
|
|
|
import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
@@ -118,6 +117,8 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
private RedisClient redisClient;
|
|
|
@Autowired
|
|
|
private ExamStudentCache examStudentCache;
|
|
|
+ @Autowired
|
|
|
+ private ExamStudentFinalScoreService examStudentFinalScoreService;
|
|
|
|
|
|
@Autowired
|
|
|
ExamStudentCloudService examStudentCloudService;
|
|
@@ -220,7 +221,14 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
- sql.append("select id,exam_student_id,exam_id,course_id,course_code,course_level,finished,student_id,student_code,student_name,identity_number"
|
|
|
+ sql.append("select id,exam_student_id,exam_id,course_id,course_code,course_level");
|
|
|
+ if ((ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) && query.getFinished() == null) {
|
|
|
+ sql.append(",case when finished = 1 OR t1.exam_student_id in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + query.getExamId() + " ) then 1 else 0 end finished");
|
|
|
+ } else {
|
|
|
+ sql.append(",finished");
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append(",student_id,student_code,student_name,identity_number"
|
|
|
+ ",info_collector,root_org_id,org_id,paper_type,used_num,extra_num"
|
|
|
+ ",specialty_code,specialty_name,grade from ec_oe_exam_student t1 where 1=1 ");
|
|
|
sql.append(selectExamStudentConfitionSql(query, examBean.getExamType()));
|
|
@@ -240,6 +248,19 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
for (ExamStudentEntity examStudentEntity : examStudentList) {
|
|
|
ExamStudentInfo examStudentInfo = buildExamStudentInfo(examStudentEntity, cahcheMap, examBean.getExamType());
|
|
|
examStudentInfoList.add(examStudentInfo);
|
|
|
+ if (ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) {
|
|
|
+ if (query.getFinished() != null) {
|
|
|
+ if (query.getFinished().intValue() == 1) {
|
|
|
+ examStudentInfo.setFinished(true);
|
|
|
+ examStudentInfo.setFinishedStatus(FinishStatus.已完成.name());
|
|
|
+ }
|
|
|
+ if (query.getFinished().intValue() == 0) {
|
|
|
+ examStudentInfo.setFinished(false);
|
|
|
+ examStudentInfo.setFinishedStatus(FinishStatus.未完成.name());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ countUseExamTimes(examStudentInfo, examBean.getExamType());
|
|
|
+ }
|
|
|
}
|
|
|
cahcheMap.clear();
|
|
|
Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize());
|
|
@@ -262,7 +283,14 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
//查询条件
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
- sql.append("select id,exam_student_id,exam_id,course_id,course_code,course_level,finished,student_id,student_code,student_name,identity_number"
|
|
|
+ sql.append("select id,exam_student_id,exam_id,course_id,course_code,course_level");
|
|
|
+ if ((ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) && query.getFinished() == null) {
|
|
|
+ sql.append(",case when finished = 1 OR t1.exam_student_id in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + query.getExamId() + " ) then 1 else 0 end finished");
|
|
|
+ } else {
|
|
|
+ sql.append(",finished");
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append(",student_id,student_code,student_name,identity_number"
|
|
|
+ ",info_collector,root_org_id,org_id,paper_type,used_num,extra_num"
|
|
|
+ ",specialty_code,specialty_name,grade from ec_oe_exam_student t1 where 1=1 ");
|
|
|
sql.append(selectExamStudentConfitionSql(query, examBean.getExamType()));
|
|
@@ -280,6 +308,19 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
for (ExamStudentEntity examStudentEntity : examStudentList) {
|
|
|
ExamStudentInfo examStudentInfo = buildExamStudentInfo(examStudentEntity, cahcheMap, examBean.getExamType());
|
|
|
examStudentInfoList.add(examStudentInfo);
|
|
|
+ if (ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) {
|
|
|
+ if (query.getFinished() != null) {
|
|
|
+ if (query.getFinished().intValue() == 1) {
|
|
|
+ examStudentInfo.setFinished(true);
|
|
|
+ examStudentInfo.setFinishedStatus(FinishStatus.已完成.name());
|
|
|
+ }
|
|
|
+ if (query.getFinished().intValue() == 0) {
|
|
|
+ examStudentInfo.setFinished(false);
|
|
|
+ examStudentInfo.setFinishedStatus(FinishStatus.未完成.name());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ countUseExamTimes(examStudentInfo, examBean.getExamType());
|
|
|
+ }
|
|
|
}
|
|
|
cahcheMap.clear();
|
|
|
return examStudentInfoList;
|
|
@@ -300,7 +341,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
sql.append(" and student_name LIKE '%" + query.getStudentName() + "%'");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(query.getIdentityNumber())) {
|
|
|
- sql.append(" and identity_number LIKE '%" + query.getIdentityNumber() + "%'");
|
|
|
+ sql.append(" and identity_number LIKE '" + query.getIdentityNumber() + "%'");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(query.getInfoCollector())) {
|
|
|
sql.append(" and info_collector LIKE '%" + query.getInfoCollector() + "%'");
|
|
@@ -312,8 +353,14 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
sql.append(" and course_level= '" + query.getCourseLevel() + "'");
|
|
|
}
|
|
|
if (query.getFinished() != null) {
|
|
|
- if (ExamType.ONLINE.name().equals(examType)) {
|
|
|
- sql.append(" and finished = " + query.getFinished());
|
|
|
+ if (ExamType.ONLINE.name().equals(examType) || ExamType.ONLINE_HOMEWORK.name().equals(examType)) {
|
|
|
+// sql.append(" and finished = " + query.getFinished());
|
|
|
+ if (query.getFinished().intValue() == 1) {
|
|
|
+ sql.append(" AND ( finished = 1 OR t1.exam_student_id in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + query.getExamId() + " ) )");
|
|
|
+ }
|
|
|
+ if (query.getFinished().intValue() == 0) {
|
|
|
+ sql.append(" AND ( finished = 0 and t1.exam_student_id not in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + query.getExamId() + " ) )");
|
|
|
+ }
|
|
|
} else if (ExamType.OFFLINE.name().equals(examType)) {
|
|
|
//如果忽略是否上传答案时,只要是已抽题则认为已参加考试
|
|
|
if (query.getIgnoreUploadOfflineAnswer() != null && true == query.getIgnoreUploadOfflineAnswer()) {
|
|
@@ -348,7 +395,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
String photoNumber = localCacheService.getStudentPhotoNumber(cahcheMap, examStudentInfo.getStudentId());
|
|
|
examStudentInfo.setPhone(photoNumber);//电话号码
|
|
|
|
|
|
- if (ExamType.ONLINE.name().equals(examType)) {
|
|
|
+ if (ExamType.ONLINE.name().equals(examType) || ExamType.ONLINE_HOMEWORK.name().equals(examType)) {
|
|
|
//完成状态
|
|
|
examStudentInfo.setFinishedStatus(examStudentEntity.getFinished() ? FinishStatus.已完成.name() : FinishStatus.未完成.name());
|
|
|
} else if (ExamType.OFFLINE.name().equals(examType)) {
|
|
@@ -449,7 +496,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
sql.append(" and t.student_name LIKE '%" + query.getStudentName() + "%'");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(query.getIdentityNumber())) {
|
|
|
- sql.append(" and t.identity_number LIKE '%" + query.getIdentityNumber() + "%'");
|
|
|
+ sql.append(" and t.identity_number LIKE '" + query.getIdentityNumber() + "%'");
|
|
|
}
|
|
|
if (query.getCourseId() != null && StringUtils.isNotBlank(query.getCourseId() + "")) {
|
|
|
sql.append(" and t.course_id=" + query.getCourseId());
|
|
@@ -523,7 +570,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
sql.append(" and student.student_name LIKE '%" + query.getStudentName() + "%'");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(query.getIdentityNumber())) {
|
|
|
- sql.append(" and student.identity_number LIKE '%" + query.getIdentityNumber() + "%'");
|
|
|
+ sql.append(" and student.identity_number LIKE '" + query.getIdentityNumber() + "%'");
|
|
|
}
|
|
|
if (query.getCourseId() != null && StringUtils.isNotBlank(query.getCourseId() + "")) {
|
|
|
sql.append(" and student.course_id=" + query.getCourseId());
|
|
@@ -536,51 +583,107 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
@Override
|
|
|
public ExamStudentFinishedStatistic getExamStudentStatisticByFinished(Long examId) {
|
|
|
- SqlWrapper wrapper = new SqlWrapper()
|
|
|
- .select(statisticFinishedColumns())
|
|
|
- .from("ec_oe_exam_student").as("student")
|
|
|
- .where().eq("student.exam_id", examId);
|
|
|
- Query dataQuery = entityManager.createNativeQuery(wrapper.build());
|
|
|
-// dataQuery.unwrap(SQLQuery.class).setResultTransformer(Transformers.aliasToBean(HashMap.class));
|
|
|
- dataQuery.unwrap(NativeQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
|
|
- Map<String, BigDecimal> map = (HashMap) dataQuery.getSingleResult();
|
|
|
- ExamStudentFinishedStatistic statistic = new ExamStudentFinishedStatistic();
|
|
|
- if (map != null) {
|
|
|
- if (map.get("finished") == null) {
|
|
|
- statistic.setFinished(0);
|
|
|
- } else {
|
|
|
- statistic.setFinished(map.get("finished").intValue());
|
|
|
- }
|
|
|
- if (map.get("unFinished") == null) {
|
|
|
- statistic.setUnFinished(0);
|
|
|
- } else {
|
|
|
- statistic.setUnFinished(map.get("unFinished").intValue());
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
|
|
|
+ if (ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) {
|
|
|
+ ExamStudentFinishedStatistic statistic = new ExamStudentFinishedStatistic();
|
|
|
+ StringBuffer totalsql = new StringBuffer();
|
|
|
+ totalsql.append("select count(t1.id) from ec_oe_exam_student t1 where 1=1 ");
|
|
|
+ totalsql.append(" and exam_id = " + examId);
|
|
|
+ Integer total = jdbcTemplate.queryForObject(totalsql.toString(), Integer.class);
|
|
|
+
|
|
|
+ StringBuffer finishsql = new StringBuffer();
|
|
|
+ finishsql.append("select count(t1.id) from ec_oe_exam_student t1 where 1=1 ");
|
|
|
+ finishsql.append(" and exam_id = " + examId);
|
|
|
+ finishsql.append(" AND ( finished = 1 OR t1.exam_student_id in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + examId + " ) )");
|
|
|
+ Integer finish = jdbcTemplate.queryForObject(finishsql.toString(), Integer.class);
|
|
|
+ statistic.setFinished(finish);
|
|
|
+ statistic.setUnFinished(total - finish);
|
|
|
+ return statistic;
|
|
|
+ } else {
|
|
|
+ SqlWrapper wrapper = new SqlWrapper()
|
|
|
+ .select(statisticFinishedColumns())
|
|
|
+ .from("ec_oe_exam_student").as("student")
|
|
|
+ .where().eq("student.exam_id", examId);
|
|
|
+ Query dataQuery = entityManager.createNativeQuery(wrapper.build());
|
|
|
+ dataQuery.unwrap(NativeQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
|
|
+ Map<String, BigDecimal> map = (HashMap) dataQuery.getSingleResult();
|
|
|
+ ExamStudentFinishedStatistic statistic = new ExamStudentFinishedStatistic();
|
|
|
+ if (map != null) {
|
|
|
+ if (map.get("finished") == null) {
|
|
|
+ statistic.setFinished(0);
|
|
|
+ } else {
|
|
|
+ statistic.setFinished(map.get("finished").intValue());
|
|
|
+ }
|
|
|
+ if (map.get("unFinished") == null) {
|
|
|
+ statistic.setUnFinished(0);
|
|
|
+ } else {
|
|
|
+ statistic.setUnFinished(map.get("unFinished").intValue());
|
|
|
+ }
|
|
|
}
|
|
|
+ return statistic;
|
|
|
}
|
|
|
- return statistic;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<ExamStudentOrgStatistic> getExamStudentStatisticByOrg(Long examId, Long orgId) {
|
|
|
- SqlWrapper wrapper = new SqlWrapper()
|
|
|
- .select(statisticOrgColumns())
|
|
|
- .from("ec_oe_exam_student").as("student")
|
|
|
- .where().eq("student.exam_id", examId);
|
|
|
- if (orgId != null) {
|
|
|
- wrapper.and().eq("student.org_id", orgId);
|
|
|
- }
|
|
|
- wrapper.groupBy("student.org_id").orderBy("student.org_id", false);
|
|
|
- Query dataQuery = entityManager.createNativeQuery(wrapper.build());
|
|
|
-// dataQuery.unwrap(SQLQuery.class).setResultTransformer(Transformers.aliasToBean(HashMap.class));
|
|
|
- dataQuery.unwrap(NativeQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
|
|
- List<ExamStudentOrgStatistic> examStudentOrgStatisticList = ExamStudentEntityConvert.ofList(dataQuery.getResultList());
|
|
|
- Map<String, Object> cahcheMap = new HashMap<String, Object>();
|
|
|
- for (ExamStudentOrgStatistic statistic : examStudentOrgStatisticList) {
|
|
|
- OrgCacheBean orgBean = gainBaseDataService.getOrgBean(statistic.getOrgId());
|
|
|
- statistic.setOrgCode(orgBean.getCode());
|
|
|
- statistic.setOrgName(orgBean.getName());
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
|
|
|
+ if (ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) {
|
|
|
+ StringBuffer totalsql = new StringBuffer();
|
|
|
+ totalsql.append("select t1.org_id orgId,count(t1.id) totalCount from ec_oe_exam_student t1 where 1=1 ");
|
|
|
+ totalsql.append(" and exam_id = " + examId);
|
|
|
+ if (orgId != null) {
|
|
|
+ totalsql.append(" and org_id = " + orgId);
|
|
|
+ }
|
|
|
+ totalsql.append(" group by t1.org_id ");
|
|
|
+ List<ExamStudentOrgStatistic> totalList = jdbcTemplate.query(totalsql.toString(), new BeanPropertyRowMapper<ExamStudentOrgStatistic>(ExamStudentOrgStatistic.class));
|
|
|
+
|
|
|
+ StringBuffer finishsql = new StringBuffer();
|
|
|
+ finishsql.append("select t1.org_id orgId,count(t1.id) finishedCount from ec_oe_exam_student t1 where 1=1 ");
|
|
|
+ finishsql.append(" and exam_id = " + examId);
|
|
|
+ if (orgId != null) {
|
|
|
+ finishsql.append(" and org_id = " + orgId);
|
|
|
+ }
|
|
|
+ finishsql.append(" AND ( finished = 1 OR t1.exam_student_id in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + examId + " ) )");
|
|
|
+ finishsql.append(" group by t1.org_id ");
|
|
|
+
|
|
|
+ List<ExamStudentOrgStatistic> finishList = jdbcTemplate.query(finishsql.toString(), new BeanPropertyRowMapper<ExamStudentOrgStatistic>(ExamStudentOrgStatistic.class));
|
|
|
+
|
|
|
+ Map<Long, ExamStudentOrgStatistic> finishMap = finishList.stream().collect(Collectors.toMap(ExamStudentOrgStatistic::getOrgId, account -> account));
|
|
|
+
|
|
|
+ for (ExamStudentOrgStatistic statistic : totalList) {
|
|
|
+ ExamStudentOrgStatistic finish = finishMap.get(statistic.getOrgId());
|
|
|
+ statistic.setFinishedCount(finish == null ? 0 : finish.getFinishedCount());
|
|
|
+ OrgCacheBean orgBean = gainBaseDataService.getOrgBean(statistic.getOrgId());
|
|
|
+ statistic.setOrgCode(orgBean.getCode());
|
|
|
+ statistic.setOrgName(orgBean.getName());
|
|
|
+ if (statistic.getTotalCount() == 0 || statistic.getFinishedCount() == 0) {
|
|
|
+ statistic.setFinishedPercent("0");
|
|
|
+ } else {
|
|
|
+ double percent = (double) statistic.getFinishedCount() / statistic.getTotalCount();
|
|
|
+ statistic.setFinishedPercent(new DecimalFormat("#.00").format(percent * 100));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return totalList;
|
|
|
+ } else {
|
|
|
+ SqlWrapper wrapper = new SqlWrapper()
|
|
|
+ .select(statisticOrgColumns())
|
|
|
+ .from("ec_oe_exam_student").as("student")
|
|
|
+ .where().eq("student.exam_id", examId);
|
|
|
+ if (orgId != null) {
|
|
|
+ wrapper.and().eq("student.org_id", orgId);
|
|
|
+ }
|
|
|
+ wrapper.groupBy("student.org_id").orderBy("student.org_id", false);
|
|
|
+ Query dataQuery = entityManager.createNativeQuery(wrapper.build());
|
|
|
+ dataQuery.unwrap(NativeQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
|
|
|
+ List<ExamStudentOrgStatistic> examStudentOrgStatisticList = ExamStudentEntityConvert.ofList(dataQuery.getResultList());
|
|
|
+ Map<String, Object> cahcheMap = new HashMap<String, Object>();
|
|
|
+ for (ExamStudentOrgStatistic statistic : examStudentOrgStatisticList) {
|
|
|
+ OrgCacheBean orgBean = gainBaseDataService.getOrgBean(statistic.getOrgId());
|
|
|
+ statistic.setOrgCode(orgBean.getCode());
|
|
|
+ statistic.setOrgName(orgBean.getName());
|
|
|
+ }
|
|
|
+ return examStudentOrgStatisticList;
|
|
|
}
|
|
|
- return examStudentOrgStatisticList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -601,7 +704,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void setReexamine(Long examStudentId) {
|
|
|
+ public void setReexamine(Long examStudentId, String reexamineType, String reexamineDetail) {
|
|
|
List<ExamRecordDataEntity> examRecordDataList = examRecordService.getExamRecordListByExamStudentId(examStudentId);
|
|
|
//查询出上一次重考的记录
|
|
|
Optional<ExamRecordDataEntity> examRecordOptional = examRecordDataList.stream().filter(examRecordData ->
|
|
@@ -622,12 +725,17 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
if (examRecordForMarking != null) {
|
|
|
examRecordForMarkingRepo.delete(examRecordForMarking);
|
|
|
}
|
|
|
+
|
|
|
+ //重新计算考生的最终分数
|
|
|
+ examStudentFinalScoreService.calcAndSaveFinalScore(examRecordData.getExamStudentId());
|
|
|
}
|
|
|
|
|
|
//考生表重考次数+1
|
|
|
ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examStudentId);
|
|
|
Integer extraExamNum = examStudent.getExtraNum() == null ? 0 : examStudent.getExtraNum();
|
|
|
examStudent.setExtraNum(extraExamNum + 1);
|
|
|
+ examStudent.setReexamineType(reexamineType);
|
|
|
+ examStudent.setReexamineDetail(reexamineDetail);
|
|
|
examStudentRepo.save(examStudent);
|
|
|
|
|
|
//刷新考生的缓存
|
|
@@ -639,34 +747,73 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
if (examId == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(orderColumn)) {
|
|
|
- orderColumn = "all_num";
|
|
|
- }
|
|
|
- String sql = "select *,ROUND(tb.completed_num/tb.all_num,2)*100 completed_proportion from ( " +
|
|
|
- " select " +
|
|
|
- " course_id, " +
|
|
|
- " sum(case when finished = 1 then 1 else 0 end) completed_num, " +
|
|
|
- " sum(case when finished = 0 then 1 else 0 end) no_completed_num, " +
|
|
|
- " count(course_id) all_num" +
|
|
|
- " from ec_oe_exam_student " +
|
|
|
- " where exam_id = " + examId;
|
|
|
- if (courseId != null) {
|
|
|
- sql += " and course_id = " + courseId;
|
|
|
- }
|
|
|
- sql += " group by course_id ) tb ORDER BY " + orderColumn + " desc";
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
|
|
|
+ if (ExamType.ONLINE.name().equals(examBean.getExamType()) || ExamType.ONLINE_HOMEWORK.name().equals(examBean.getExamType())) {
|
|
|
+ StringBuffer totalsql = new StringBuffer();
|
|
|
+ totalsql.append("select t1.course_id courseId,count(t1.id) allNum from ec_oe_exam_student t1 where 1=1 ");
|
|
|
+ totalsql.append(" and exam_id = " + examId);
|
|
|
+ if (courseId != null) {
|
|
|
+ totalsql.append(" and course_id = " + courseId);
|
|
|
+ }
|
|
|
+ totalsql.append(" group by t1.course_id ");
|
|
|
+ List<CourseProgressInfo> totalList = jdbcTemplate.query(totalsql.toString(), new BeanPropertyRowMapper<CourseProgressInfo>(CourseProgressInfo.class));
|
|
|
|
|
|
- return jdbcTemplate.query(sql, new RowMapper<CourseProgressInfo>() {
|
|
|
- @Override
|
|
|
- public CourseProgressInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
- CourseProgressInfo courseProgressInfo = new CourseProgressInfo();
|
|
|
- courseProgressInfo.setCourseId(rs.getLong("course_id"));
|
|
|
- courseProgressInfo.setCompletedNum(rs.getInt("completed_num"));
|
|
|
- courseProgressInfo.setNoCompletedNum(rs.getInt("no_completed_num"));
|
|
|
- courseProgressInfo.setAllNum(rs.getInt("all_num"));
|
|
|
- courseProgressInfo.setCompletedProportion(rs.getDouble("completed_proportion"));
|
|
|
- return courseProgressInfo;
|
|
|
+ StringBuffer finishsql = new StringBuffer();
|
|
|
+ finishsql.append("select t1.course_id courseId,count(t1.id) completedNum from ec_oe_exam_student t1 where 1=1 ");
|
|
|
+ finishsql.append(" and exam_id = " + examId);
|
|
|
+ if (courseId != null) {
|
|
|
+ finishsql.append(" and course_id = " + courseId);
|
|
|
}
|
|
|
- });
|
|
|
+ finishsql.append(" AND ( finished = 1 OR t1.exam_student_id in ( SELECT t2.exam_student_id FROM ec_oes_exam_record_data t2 WHERE t2.exam_id=" + examId + " ))");
|
|
|
+ finishsql.append(" group by t1.course_id ");
|
|
|
+
|
|
|
+ List<CourseProgressInfo> finishList = jdbcTemplate.query(finishsql.toString(), new BeanPropertyRowMapper<CourseProgressInfo>(CourseProgressInfo.class));
|
|
|
+
|
|
|
+ Map<Long, CourseProgressInfo> finishMap = finishList.stream().collect(Collectors.toMap(CourseProgressInfo::getCourseId, account -> account));
|
|
|
+
|
|
|
+ for (CourseProgressInfo statistic : totalList) {
|
|
|
+ CourseProgressInfo finish = finishMap.get(statistic.getCourseId());
|
|
|
+ statistic.setCompletedNum(finish == null ? 0 : finish.getCompletedNum());
|
|
|
+ if (statistic.getAllNum() == 0 || statistic.getCompletedNum() == 0) {
|
|
|
+ statistic.setCompletedProportion(0.0D);
|
|
|
+ statistic.setNoCompletedNum(0);
|
|
|
+ } else {
|
|
|
+ statistic.setNoCompletedNum(statistic.getAllNum() - statistic.getCompletedNum());
|
|
|
+ double percent = (double) statistic.getCompletedNum() / statistic.getAllNum();
|
|
|
+ statistic.setCompletedProportion(Double.valueOf(new DecimalFormat("#.00").format(percent * 100)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return totalList;
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isBlank(orderColumn)) {
|
|
|
+ orderColumn = "all_num";
|
|
|
+ }
|
|
|
+ String sql = "select *,ROUND(tb.completed_num/tb.all_num,2)*100 completed_proportion from ( " +
|
|
|
+ " select " +
|
|
|
+ " course_id, " +
|
|
|
+ " sum(case when finished = 1 then 1 else 0 end) completed_num, " +
|
|
|
+ " sum(case when finished = 0 then 1 else 0 end) no_completed_num, " +
|
|
|
+ " count(course_id) all_num" +
|
|
|
+ " from ec_oe_exam_student " +
|
|
|
+ " where exam_id = " + examId;
|
|
|
+ if (courseId != null) {
|
|
|
+ sql += " and course_id = " + courseId;
|
|
|
+ }
|
|
|
+ sql += " group by course_id ) tb ORDER BY " + orderColumn + " desc";
|
|
|
+
|
|
|
+ return jdbcTemplate.query(sql, new RowMapper<CourseProgressInfo>() {
|
|
|
+ @Override
|
|
|
+ public CourseProgressInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
+ CourseProgressInfo courseProgressInfo = new CourseProgressInfo();
|
|
|
+ courseProgressInfo.setCourseId(rs.getLong("course_id"));
|
|
|
+ courseProgressInfo.setCompletedNum(rs.getInt("completed_num"));
|
|
|
+ courseProgressInfo.setNoCompletedNum(rs.getInt("no_completed_num"));
|
|
|
+ courseProgressInfo.setAllNum(rs.getInt("all_num"));
|
|
|
+ courseProgressInfo.setCompletedProportion(rs.getDouble("completed_proportion"));
|
|
|
+ return courseProgressInfo;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -706,12 +853,12 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
* @param studentId 学生id
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<OnHandExamInfo> queryOnlineExamList(Long studentId) {
|
|
|
+ public List<OnHandExamInfo> queryOnlineExamList(Long studentId, ExamType examType) {
|
|
|
StudentCacheBean studentBean = CacheHelper.getStudent(studentId);
|
|
|
|
|
|
//获取可以考的和即将考的考试Id
|
|
|
GetOngoingExamListReq getOngoingExamListReq = new GetOngoingExamListReq();
|
|
|
- getOngoingExamListReq.setExamType(ExamType.ONLINE.name());
|
|
|
+ getOngoingExamListReq.setExamType(examType.name());
|
|
|
getOngoingExamListReq.setRootOrgId(studentBean.getRootOrgId());
|
|
|
getOngoingExamListReq.setOrgId(studentBean.getOrgId());
|
|
|
getOngoingExamListReq.setStudentId(studentId);
|
|
@@ -798,6 +945,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
examStudentInfo.setFaceEnable(FaceBiopsyHelper.isFaceEnable(rootOrgId, examId, studentId));
|
|
|
//进入考试是否验证人脸识别(强制、非强制)
|
|
|
examStudentInfo.setFaceCheck(FaceBiopsyHelper.isFaceCheck(examId, studentId));
|
|
|
+
|
|
|
//是否显示客观分
|
|
|
String isObjScoreView = ExamCacheTransferHelper.getCachedExamProperty(examId,
|
|
|
studentId, ExamProperties.IS_OBJ_SCORE_VIEW.name()).getValue();
|
|
@@ -806,6 +954,16 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
} else {
|
|
|
examStudentInfo.setIsObjScoreView(Boolean.valueOf(isObjScoreView));
|
|
|
}
|
|
|
+
|
|
|
+ //是否开放app考试
|
|
|
+ String appExamEnabled = ExamCacheTransferHelper.getCachedExamProperty(examId,
|
|
|
+ studentId, ExamProperties.APP_EXAM_ENABLED.name()).getValue();
|
|
|
+ if (StringUtils.isBlank(isObjScoreView)) {
|
|
|
+ examStudentInfo.setAppExamEnabled(false);
|
|
|
+ } else {
|
|
|
+ examStudentInfo.setAppExamEnabled(Boolean.valueOf(appExamEnabled));
|
|
|
+ }
|
|
|
+
|
|
|
return examStudentInfo;
|
|
|
}
|
|
|
|
|
@@ -836,6 +994,29 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ private void countUseExamTimes(ExamStudentInfo examStudentInfo, String examType) {
|
|
|
+ if (!ExamType.ONLINE.name().equals(examType) && !ExamType.ONLINE_HOMEWORK.name().equals(examType)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //考生已考次数
|
|
|
+ int usedNum = (examStudentInfo.getUsedNum() == null ? 0 : examStudentInfo.getUsedNum());
|
|
|
+ //缓存中开考次数
|
|
|
+ int startCount = 0;
|
|
|
+ //缓存中考试完结次数
|
|
|
+ int endCount = 0;
|
|
|
+ String key = RedisKeyHelper.getBuilder().examBossKey(examStudentInfo.getExamStudentId());
|
|
|
+ ExamBoss eb = redisClient.get(key, ExamBoss.class);
|
|
|
+ if (eb != null) {
|
|
|
+ startCount = eb.getStartCount();
|
|
|
+ endCount = eb.getEndCount();
|
|
|
+ }
|
|
|
+ Integer ret = usedNum + startCount - endCount;
|
|
|
+ if (ret < 0) {
|
|
|
+ ret = 0;
|
|
|
+ }
|
|
|
+ examStudentInfo.setUsedNum(ret);
|
|
|
+ }
|
|
|
+
|
|
|
//获取考试的考生信息
|
|
|
private ExamStudentBean getRemoteExamStudent(Long rootOrgId, Long examStudentId) {
|
|
|
GetExamStudentReq req = new GetExamStudentReq();
|
|
@@ -844,4 +1025,4 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
GetExamStudentResp resp = examStudentCloudService.getExamStudent(req);
|
|
|
return resp.getExamStudentBean();
|
|
|
}
|
|
|
-}
|
|
|
+}
|