|
@@ -18,7 +18,9 @@ import cn.com.qmth.examcloud.core.oe.admin.base.jpa.SqlWrapper;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.BatchSetDataUtil;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.DateUtils;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.ExamCaptureCameraInfoRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamCaptureRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.dao.ExamProcessRecordRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordQuestionsRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
@@ -27,8 +29,8 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.enums.*;
|
|
|
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.ExamStudentEffectiveScoreInfo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordEntityConvert;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.examrecord.ExamRecordQuery;
|
|
@@ -45,11 +47,6 @@ import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
|
|
|
import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.json.JSONArray;
|
|
|
-import org.json.JSONException;
|
|
|
-import org.json.JSONObject;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
@@ -78,8 +75,6 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
|
|
|
- private static final Logger LOG = LoggerFactory.getLogger(ExamRecordServiceImpl.class);
|
|
|
-
|
|
|
@Autowired
|
|
|
private ExamScoreRepo examScoreRepo;
|
|
|
|
|
@@ -101,14 +96,20 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
@Autowired
|
|
|
private ExamRecordEntityConvert examRecordEntityConvert;
|
|
|
|
|
|
- @Autowired
|
|
|
- private LocalCacheService localCacheService;
|
|
|
+// @Autowired
|
|
|
+// private LocalCacheService localCacheService;
|
|
|
|
|
|
@Autowired
|
|
|
private StudentCloudService studentCloudService;
|
|
|
|
|
|
@Autowired
|
|
|
private ExamCaptureRepo examCaptureRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamCaptureCameraInfoRepo examCaptureCameraInfoRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamProcessRecordRepo examProcessRecordRepo;
|
|
|
|
|
|
|
|
|
private static final String EXAM_RECORD_EXPORT_SQL = "select record_data.id," +
|
|
@@ -152,7 +153,6 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
"record_data.switch_screen_count switchScreenCount," +
|
|
|
"record_data.exam_stage_id examStageId," +
|
|
|
"audit.audit_user_name audit_user_name," +
|
|
|
- "GROUP_CONCAT(DISTINCT process.source_ip) ip," +
|
|
|
"eoes.objective_score objectiveTotalScore," +
|
|
|
"eoes.subjective_score subjectiveTotalScore," +
|
|
|
"eoes.total_score paperTotalScore," +
|
|
@@ -164,12 +164,13 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
" LEFT JOIN ec_oe_exam_audit AS audit ON record_data.id = audit.exam_record_data_id " +
|
|
|
" LEFT JOIN ec_oe_exam_score eoes ON record_data.id = eoes.exam_record_data_id " +
|
|
|
" LEFT JOIN ec_oe_exam_student eoest ON record_data.exam_student_id = eoest.exam_student_id " +
|
|
|
+ " left join ec_oe_exam_capture_camera_info camera on record_data.id=camera.exam_record_data_id "+
|
|
|
" where 1=1";
|
|
|
|
|
|
/**
|
|
|
* ec_oe_exam_record_data 查询sql
|
|
|
*/
|
|
|
- private static final String EXAM_RECORD_SQL = "select record_data.id," +
|
|
|
+ private static final String EXAM_RECORD_HEAD_SQL = "select record_data.id," +
|
|
|
"record_data.exam_record_status," +
|
|
|
"record_data.start_time," +
|
|
|
"record_data.end_time," +
|
|
@@ -209,11 +210,12 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
"record_data.info_collector info_collector," +
|
|
|
"record_data.switch_screen_count switchScreenCount," +
|
|
|
"record_data.exam_stage_id examStageId," +
|
|
|
- "audit.audit_user_name audit_user_name," +
|
|
|
- "GROUP_CONCAT(DISTINCT process.source_ip) ip" +
|
|
|
- " from ec_oe_exam_record_data record_data " +
|
|
|
+ "audit.audit_user_name audit_user_name ";
|
|
|
+
|
|
|
+ private static final String EXAM_RECORD_FROM_SQL = " from ec_oe_exam_record_data record_data " +
|
|
|
" LEFT JOIN ec_oe_exam_process_record AS process ON record_data.id = process.exam_record_data_id " +
|
|
|
" LEFT JOIN ec_oe_exam_audit AS audit ON record_data.id = audit.exam_record_data_id " +
|
|
|
+ " left join ec_oe_exam_capture_camera_info camera on record_data.id=camera.exam_record_data_id "+
|
|
|
" where 1=1";
|
|
|
|
|
|
/**
|
|
@@ -231,61 +233,64 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
|
|
|
|
@Override
|
|
|
- public Page<ExamRecordInfo> getExamRecordDetailListForPage(ExamRecordQuery query) {
|
|
|
+ public Page<ExamRecordInfo> getExamRecordDetailListForPage(UserDataRules uds,ExamRecordQuery query) {
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
|
Check.isNull(query.getExamId(), "请先选择考试批次!");
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
- return this.loadData(_getExamRecordDetailListForPage(query), query.getExamId());
|
|
|
+ return this.loadData(_getExamRecordDetailListForPage(uds,query), query.getExamId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<ExamRecordInfo> getExamRecordWaitingAuditList(ExamRecordQuery query) {
|
|
|
+ public Page<ExamRecordInfo> getExamRecordWaitingAuditList(UserDataRules uds,ExamRecordQuery query) {
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
|
Check.isNull(query.getExamId(), "请先选择考试批次!");
|
|
|
//默认条件
|
|
|
query.setIsAudit(false);
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
- return this.getExamRecordList(query);
|
|
|
+ return this.getExamRecordList(uds,query);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<ExamRecordInfo> getExamRecordWaitingAudit(ExamRecordQuery query) {
|
|
|
- Check.isNull(query, "查询参数不能为空!");
|
|
|
- //默认条件
|
|
|
- query.setIsAudit(false);
|
|
|
- query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
- query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
-
|
|
|
- //查询条件
|
|
|
- StringBuilder sqlBuilder = new StringBuilder();
|
|
|
- //待审核(按原先的sql,多了一个ip字段)
|
|
|
- sqlBuilder.append(EXAM_RECORD_SQL);
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
- if (query.getIsWarn() != null) {
|
|
|
- //只查有异常未审核
|
|
|
- if (query.getIsWarn()) {
|
|
|
- sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0 ");
|
|
|
- } else {
|
|
|
- sqlBuilder.append(" and record_data.is_warn = 0 ");
|
|
|
- }
|
|
|
- } else {
|
|
|
- sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 0))");
|
|
|
- }
|
|
|
- sqlBuilder.append(" and record_data.is_illegality = 0");
|
|
|
- //查询分页记录
|
|
|
- sqlBuilder.append(" group by record_data.id ");
|
|
|
-
|
|
|
- sqlBuilder.append(" order by record_data.id desc");
|
|
|
- List<ExamRecordDataEntity> entities = jdbcTemplate.query(sqlBuilder.toString(), (rs, rowNum) -> getExamRecordDataEntityByResultSet(rs));
|
|
|
-
|
|
|
- return examRecordEntityConvert.ofList(entities);
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public List<ExamRecordInfo> getExamRecordWaitingAudit(ExamRecordQuery query) {
|
|
|
+// Check.isNull(query, "查询参数不能为空!");
|
|
|
+// //默认条件
|
|
|
+// query.setIsAudit(false);
|
|
|
+// query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
+// query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
+//
|
|
|
+// //查询条件
|
|
|
+// StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+// //待审核(按原先的sql,多了一个ip字段)
|
|
|
+// sqlBuilder.append(EXAM_RECORD_SQL);
|
|
|
+// sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+// if (query.getIsWarn() != null) {
|
|
|
+// //只查有异常未审核
|
|
|
+// if (query.getIsWarn()) {
|
|
|
+// sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0 ");
|
|
|
+// } else {
|
|
|
+// sqlBuilder.append(" and record_data.is_warn = 0 ");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 0))");
|
|
|
+// }
|
|
|
+// sqlBuilder.append(" and record_data.is_illegality = 0");
|
|
|
+// //查询分页记录
|
|
|
+// sqlBuilder.append(" group by record_data.id ");
|
|
|
+//
|
|
|
+// sqlBuilder.append(" order by record_data.id desc");
|
|
|
+// List<ExamRecordDataEntity> entities = jdbcTemplate.query(sqlBuilder.toString(), (rs, rowNum) -> getExamRecordDataEntityByResultSet(rs));
|
|
|
+//
|
|
|
+// return examRecordEntityConvert.ofList(entities);
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
- public Long getExamRecordWaitingAuditNextId(ExamRecordQuery query, Long examRecordDataId, String next) {
|
|
|
- Check.isNull(query, "查询参数不能为空!");
|
|
|
+ public Long getExamRecordWaitingAuditNextId(UserDataRules uds,ExamRecordQuery query, Long examRecordDataId, String next) {
|
|
|
+ if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Check.isNull(query, "查询参数不能为空!");
|
|
|
Check.isNull(query.getExamId(), "请先选择考试批次!");
|
|
|
//默认条件
|
|
|
query.setIsWarn(true);
|
|
@@ -294,9 +299,8 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
//查询条件
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
- //待审核(按原先的sql,多了一个ip字段)
|
|
|
sqlBuilder.append("select record_data.id from ec_oe_exam_record_data record_data where 1 = 1 ");
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+ sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
|
|
|
if (query.getIsWarn() != null) {
|
|
|
//只查有异常未审核
|
|
|
if (query.getIsWarn()) {
|
|
@@ -341,31 +345,28 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
- private Page<ExamRecordInfo> _getExamRecordDetailListForPage(ExamRecordQuery query) {
|
|
|
+ private Page<ExamRecordInfo> _getExamRecordDetailListForPage(UserDataRules uds,ExamRecordQuery query) {
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
|
Check.isNull(query.getExamId(), "请先选择考试批次!");
|
|
|
//查询条件
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
- sqlBuilder.append(EXAM_RECORD_SQL);
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+ sqlBuilder.append(EXAM_RECORD_FROM_SQL);
|
|
|
+ sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
|
|
|
sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 1))");
|
|
|
sqlBuilder.append(" group by record_data.id ");
|
|
|
- //根据ip查询
|
|
|
- /*if (StringUtils.isNoneBlank(query.getIp())) {
|
|
|
- sqlBuilder.append(" having ip like '%"+query.getIp()+"%' ");
|
|
|
- }*/
|
|
|
- sqlBuilder.append(" order by record_data.id desc");
|
|
|
//分页条件
|
|
|
int currentNum = (query.getPageNo() - 1) * query.getPageSize();
|
|
|
- sqlBuilder.append(" limit " + currentNum + "," + query.getPageSize());
|
|
|
- List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(sqlBuilder.toString(), new RowMapper<ExamRecordDataEntity>() {
|
|
|
+ List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(
|
|
|
+ EXAM_RECORD_HEAD_SQL+sqlBuilder.toString()+" order by record_data.id desc limit " + currentNum + "," + query.getPageSize(),
|
|
|
+ new RowMapper<ExamRecordDataEntity>() {
|
|
|
@Override
|
|
|
public ExamRecordDataEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
return getExamRecordDataEntityByResultSet(rs);
|
|
|
}
|
|
|
});
|
|
|
//查询总数
|
|
|
- long total = countExamRecordDetailListForPage(query);
|
|
|
+// long total = countExamRecordDetailListForPage(query);
|
|
|
+ long total=jdbcTemplate.queryForObject("SELECT count(1) FROM (SELECT record_data.id "+sqlBuilder.toString()+") temtb", Long.class);
|
|
|
Pageable pageable = PageRequest.of(query.getPageNo() - 1, query.getPageSize());
|
|
|
Page<ExamRecordDataEntity> page = new PageImpl<ExamRecordDataEntity>(examRecordDataList, pageable, total);
|
|
|
Page<ExamRecordInfo> ret=examRecordEntityConvert.of(page);
|
|
@@ -411,7 +412,6 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
examRecordData.setFaceSuccessPercent(rs.getDouble("face_success_percent"));
|
|
|
examRecordData.setFaceVerifyResult(IsSuccess.strToEnum(rs.getString("face_verify_result")));
|
|
|
examRecordData.setBaiduFaceLivenessSuccessPercent(rs.getDouble("baidu_face_liveness_success_percent"));
|
|
|
- examRecordData.setIp(rs.getString("ip"));
|
|
|
examRecordData.setAuditUserName(rs.getString("audit_user_name"));
|
|
|
examRecordData.setSwitchScreenCount(rs.getInt("switchScreenCount"));
|
|
|
if(rs.getString("examStageId")!=null) {
|
|
@@ -421,14 +421,16 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
return examRecordData;
|
|
|
}
|
|
|
|
|
|
- private long countExamRecordDetailListForPage(ExamRecordQuery query) {
|
|
|
- StringBuilder sqlBuilder = new StringBuilder();
|
|
|
- sqlBuilder.append("select count(record_data.id) from ec_oe_exam_record_data record_data " +
|
|
|
- "LEFT JOIN ec_oe_exam_audit AS audit ON record_data.id = audit.exam_record_data_id where 1=1");
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
- sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 1))");
|
|
|
- return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
|
- }
|
|
|
+// private long countExamRecordDetailListForPage(ExamRecordQuery query) {
|
|
|
+// StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+// sqlBuilder.append("select count(distinct record_data.id) from ec_oe_exam_record_data record_data " +
|
|
|
+// " LEFT JOIN ec_oe_exam_process_record AS process ON record_data.id = process.exam_record_data_id " +
|
|
|
+// " LEFT JOIN ec_oe_exam_audit AS audit ON record_data.id = audit.exam_record_data_id where 1=1 ");
|
|
|
+// sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+// sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 1))");
|
|
|
+// sqlBuilder.append(" group by record_data.id ");
|
|
|
+// return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 构建查询 考试明细sql语句
|
|
@@ -436,7 +438,7 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
- private StringBuilder buildExamRecordCommonSelectCondition(ExamRecordQuery query) {
|
|
|
+ private StringBuilder buildExamRecordCommonSelectCondition(UserDataRules uds,ExamRecordQuery query) {
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
if (query.getSwitchScreenCountStart() != null) {
|
|
|
sql.append(" and record_data.switch_screen_count >= " +query.getSwitchScreenCountStart());
|
|
@@ -529,13 +531,29 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
//是否有虚拟设备
|
|
|
if (query.getHasVirtual() != null) {
|
|
|
if (query.getHasVirtual()) {
|
|
|
- sql.append(" and record_data.id in (select t1.id from ec_oe_exam_record_data t1 left join ec_oe_exam_capture t2 on t1.id=t2.exam_record_data_id where t1.exam_id =" + query.getExamId() + " and t2.has_virtual_camera=1 )");
|
|
|
+ sql.append(" and camera.virtual_camera=1 ");
|
|
|
+// sql.append(" and record_data.id in (select t1.id from ec_oe_exam_record_data t1 left join ec_oe_exam_capture t2 on t1.id=t2.exam_record_data_id where t1.exam_id =" + query.getExamId() + " and t2.has_virtual_camera=1 )");
|
|
|
} else {
|
|
|
//原先写法会跟有虚拟设备的出现重复情况,用有虚拟设备的not in
|
|
|
//sql.append(" and record_data.id in (select t1.id from ec_oe_exam_record_data t1 left join ec_oe_exam_capture t2 on t1.id=t2.exam_record_data_id where t1.exam_id =" + query.getExamId()+" and (t2.has_virtual_camera=0 or t2.has_virtual_camera is null) )");
|
|
|
- sql.append(" and record_data.id not in (select t1.id from ec_oe_exam_record_data t1 left join ec_oe_exam_capture t2 on t1.id=t2.exam_record_data_id where t1.exam_id =" + query.getExamId() + " and t2.has_virtual_camera=1 )");
|
|
|
+// sql.append(" and record_data.id not in (select t1.id from ec_oe_exam_record_data t1 left join ec_oe_exam_capture t2 on t1.id=t2.exam_record_data_id where t1.exam_id =" + query.getExamId() + " and t2.has_virtual_camera=1 )");
|
|
|
+ sql.append(" and (camera.virtual_camera=0 or camera.virtual_camera is null) ");
|
|
|
}
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(query.getVirtualName())) {
|
|
|
+ sql.append(" and camera.name='"+query.getVirtualName()+"' ");
|
|
|
+ }
|
|
|
+
|
|
|
+ //ip
|
|
|
+ if (StringUtils.isNotBlank(query.getIp())) {
|
|
|
+ sql.append(" and process.source_ip='"+query.getIp()+"' ");
|
|
|
+ }
|
|
|
+ if(uds.getOrgRule().assertNeedQueryRefIds()) {
|
|
|
+ sql.append(" and record_data.org_id in (" + StringUtils.join(uds.getOrgRule().getRefIds(), ",")+") ");
|
|
|
+ }
|
|
|
+ if(uds.getCourseRule().assertNeedQueryRefIds()) {
|
|
|
+ sql.append(" and record_data.course_id in (" + StringUtils.join(uds.getCourseRule().getRefIds(), ",")+") ");
|
|
|
+ }
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
@@ -544,13 +562,16 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
* 查询无异常的数据和有异常未审核的数据
|
|
|
*/
|
|
|
@Override
|
|
|
- public Page<ExamRecordInfo> getExamRecordList(ExamRecordQuery query) {
|
|
|
+ public Page<ExamRecordInfo> getExamRecordList(UserDataRules uds,ExamRecordQuery query) {
|
|
|
+ if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
|
|
|
+ return Page.empty();
|
|
|
+ }
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
|
//查询条件
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
//待审核(按原先的sql,多了一个ip字段)
|
|
|
- sqlBuilder.append(EXAM_RECORD_SQL);
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+ sqlBuilder.append(EXAM_RECORD_FROM_SQL);
|
|
|
+ sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
|
|
|
if (query.getIsWarn() != null) {
|
|
|
//只查有异常未审核
|
|
|
if (query.getIsWarn()) {
|
|
@@ -564,22 +585,20 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
sqlBuilder.append(" and record_data.is_illegality = 0");
|
|
|
//查询分页记录
|
|
|
sqlBuilder.append(" group by record_data.id ");
|
|
|
- //根据ip查询
|
|
|
- /*if (StringUtils.isNoneBlank(query.getIp())) {
|
|
|
- sqlBuilder.append(" having ip like '%"+query.getIp()+"%' ");
|
|
|
- }*/
|
|
|
- sqlBuilder.append(" order by record_data.id desc");
|
|
|
+// sqlBuilder.append(" order by record_data.id desc");
|
|
|
//分页条件
|
|
|
int currentNum = (query.getPageNo() - 1) * query.getPageSize();
|
|
|
- sqlBuilder.append(" limit " + currentNum + "," + query.getPageSize());
|
|
|
- List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(sqlBuilder.toString(), new RowMapper<ExamRecordDataEntity>() {
|
|
|
+// sqlBuilder.append(" limit " + currentNum + "," + query.getPageSize());
|
|
|
+ List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(
|
|
|
+ EXAM_RECORD_HEAD_SQL+sqlBuilder.toString()+" order by record_data.id desc limit " + currentNum + "," + query.getPageSize(), new RowMapper<ExamRecordDataEntity>() {
|
|
|
@Override
|
|
|
public ExamRecordDataEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
return getExamRecordDataEntityByResultSet(rs);
|
|
|
}
|
|
|
});
|
|
|
//查询总数
|
|
|
- long total = countExamRecordListForPage(query);
|
|
|
+// long total = countExamRecordListForPage(query);
|
|
|
+ long total=jdbcTemplate.queryForObject("SELECT count(1) FROM (SELECT record_data.id "+sqlBuilder.toString()+") temtb", Long.class);
|
|
|
Pageable pageable = PageRequest.of(query.getPageNo() - 1, query.getPageSize());
|
|
|
|
|
|
Page<ExamRecordDataEntity> page = new PageImpl<ExamRecordDataEntity>(examRecordDataList, pageable, total);
|
|
@@ -590,24 +609,25 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
* 监考待审:数量查询
|
|
|
* 查询无异常的数据和有异常未审核的数据
|
|
|
*/
|
|
|
- private long countExamRecordListForPage(ExamRecordQuery query) {
|
|
|
- StringBuilder sqlBuilder = new StringBuilder();
|
|
|
- sqlBuilder.append("select count(record_data.id) from ec_oe_exam_record_data record_data where 1=1");
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
- if (query.getIsWarn() != null) {
|
|
|
- if (query.getIsWarn()) {
|
|
|
- sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0 ");
|
|
|
- } else {
|
|
|
- sqlBuilder.append(" and record_data.is_warn = 0 ");
|
|
|
- }
|
|
|
- } else {
|
|
|
- sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 0))");
|
|
|
- }
|
|
|
- sqlBuilder.append(" and record_data.is_illegality = 0");
|
|
|
- return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
+// private long countExamRecordListForPage(ExamRecordQuery query) {
|
|
|
+// StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+// sqlBuilder.append("select count(record_data.id) from ec_oe_exam_record_data record_data where 1=1");
|
|
|
+// sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+// if (query.getIsWarn() != null) {
|
|
|
+// if (query.getIsWarn()) {
|
|
|
+// sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0 ");
|
|
|
+// } else {
|
|
|
+// sqlBuilder.append(" and record_data.is_warn = 0 ");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 0))");
|
|
|
+// }
|
|
|
+// sqlBuilder.append(" and record_data.is_illegality = 0");
|
|
|
+// return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
|
+// }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ @Override
|
|
|
public List<Long> getExamRecordingStudentIds(Long examId) {
|
|
|
Check.isNull(examId, "考试ID不能为空!");
|
|
|
|
|
@@ -701,17 +721,20 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Long existsWarnExamRecordDetail(ExamRecordQuery query) {
|
|
|
+ public Long existsWarnExamRecordDetail(UserDataRules uds,ExamRecordQuery query) {
|
|
|
+ if(uds.getCourseRule().assertEmptyQueryResult()||uds.getOrgRule().assertEmptyQueryResult()) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
sqlBuilder.append("select count(record_data.id) from ec_oe_exam_record_data record_data "
|
|
|
+ " where 1=1 ");
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+ sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
|
|
|
sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0");
|
|
|
return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ExamRecordInfo> getExamRecordDetailListForAsync(ExamRecordQuery query) {
|
|
|
+ public List<ExamRecordInfo> getExamRecordDetailListForAsync(UserDataRules uds,ExamRecordQuery query) {
|
|
|
Check.isNull(query, "查询参数不能为空!");
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
@@ -719,7 +742,7 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
List<ExamRecordInfo> examRecordDataList = new ArrayList<ExamRecordInfo>();
|
|
|
Long startId = 0L;
|
|
|
for (; ; ) {
|
|
|
- List<ExamRecordInfo> tem = getExamRecordDetailPageForExport(query, startId);
|
|
|
+ List<ExamRecordInfo> tem = getExamRecordDetailPageForExport(uds,query, startId);
|
|
|
if (tem == null || tem.size() == 0) {
|
|
|
break;
|
|
|
} else {
|
|
@@ -737,6 +760,7 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
String examType = examRecordDataList.get(0).getExamType();
|
|
|
if (ExamType.ONLINE.name().equals(examType) || ExamType.ONLINE_HOMEWORK.name().equals(examType)) {
|
|
|
setVirtualCameraNames(examRecordDataList);
|
|
|
+ setIps(examRecordDataList);
|
|
|
}
|
|
|
fillStage(examRecordDataList);
|
|
|
return examRecordDataList;
|
|
@@ -813,36 +837,17 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
public void setData(List<ExamRecordInfo> dataList) {
|
|
|
List<Long> ids = dataList.stream().map(dto -> dto.getId()).distinct().collect(Collectors.toList());
|
|
|
Map<Long, Set<String>> map = new HashMap<>();
|
|
|
- List<ExamCaptureEntity> examCaptureList = examCaptureRepo.findByExamRecordDataIdIn(ids);
|
|
|
+ List<ExamCaptureCameraInfoEntity> examCaptureList = examCaptureCameraInfoRepo.findByExamRecordDataIdInAndVirtualCamera(ids,true);
|
|
|
if (examCaptureList != null && examCaptureList.size() > 0) {
|
|
|
- for (ExamCaptureEntity examCapture : examCaptureList) {
|
|
|
+ for (ExamCaptureCameraInfoEntity examCapture : examCaptureList) {
|
|
|
Set<String> virtualCameraNames = map.get(examCapture.getExamRecordDataId());
|
|
|
if (virtualCameraNames == null) {
|
|
|
virtualCameraNames = new HashSet<String>();
|
|
|
map.put(examCapture.getExamRecordDataId(), virtualCameraNames);
|
|
|
}
|
|
|
- String cameraInfos = examCapture.getCameraInfos();
|
|
|
+ String cameraInfos = examCapture.getName();
|
|
|
if (StringUtils.isNotBlank(cameraInfos)) {
|
|
|
- JSONArray jsonArray;
|
|
|
- try {
|
|
|
- jsonArray = new JSONArray(cameraInfos);
|
|
|
- for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
- try {
|
|
|
- JSONObject jsonObject = (JSONObject) jsonArray.get(i);
|
|
|
- if (StringUtils.isBlank(jsonObject.getString("pid"))) {
|
|
|
- virtualCameraNames.add(jsonObject.getString("name"));
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- //主要针对json数组最后的空对象处理,不影响业务
|
|
|
- LOG.error("抓拍照片格式不正确", e);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- LOG.error("获取虚拟摄像头名称失败", e);
|
|
|
- throw new StatusException("ExamCaptureService-001", "获取虚拟摄像头名称失败");
|
|
|
- }
|
|
|
-
|
|
|
+ virtualCameraNames.add(cameraInfos);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -854,6 +859,35 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
};
|
|
|
tool.setDataForBatch(examRecordDataList, 100);
|
|
|
}
|
|
|
+
|
|
|
+ private void setIps(List<ExamRecordInfo> examRecordDataList) {
|
|
|
+ BatchSetDataUtil<ExamRecordInfo> tool = new BatchSetDataUtil<ExamRecordInfo>() {
|
|
|
+ @Override
|
|
|
+ public void setData(List<ExamRecordInfo> dataList) {
|
|
|
+ List<Long> ids = dataList.stream().map(dto -> dto.getId()).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, Set<String>> map = new HashMap<>();
|
|
|
+ List<ExamProcessRecordEntity> list = examProcessRecordRepo.findByExamRecordDataIdIn(ids);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ for (ExamProcessRecordEntity ep : list) {
|
|
|
+ Set<String> ips = map.get(ep.getExamRecordDataId());
|
|
|
+ if (ips == null) {
|
|
|
+ ips = new HashSet<String>();
|
|
|
+ map.put(ep.getExamRecordDataId(), ips);
|
|
|
+ }
|
|
|
+ String ip = ep.getSourceIp();
|
|
|
+ if (StringUtils.isNotBlank(ip)) {
|
|
|
+ ips.add(ip);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ExamRecordInfo erInfo : dataList) {
|
|
|
+ erInfo.setIp(getStrFromSet(map.get(erInfo.getId())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+ tool.setDataForBatch(examRecordDataList, 100);
|
|
|
+ }
|
|
|
|
|
|
private String getStrFromSet(Set<String> set) {
|
|
|
if (set == null || set.size() == 0) {
|
|
@@ -921,10 +955,10 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private List<ExamRecordInfo> getExamRecordDetailPageForExport(ExamRecordQuery query, Long startId) {
|
|
|
+ private List<ExamRecordInfo> getExamRecordDetailPageForExport(UserDataRules uds,ExamRecordQuery query, Long startId) {
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
sqlBuilder.append(EXAM_RECORD_EXPORT_SQL);
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+ sqlBuilder.append(buildExamRecordCommonSelectCondition(uds,query));
|
|
|
sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 1))");
|
|
|
sqlBuilder.append(" and record_data.id >" + startId);
|
|
|
sqlBuilder.append(" group by record_data.id ");
|
|
@@ -939,68 +973,68 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<ExamRecordInfo> getExamRecordDetailList(ExamRecordQuery query) {
|
|
|
- Check.isNull(query, "查询参数不能为空!");
|
|
|
- query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
- query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
-
|
|
|
- StringBuilder sqlBuilder = new StringBuilder();
|
|
|
- sqlBuilder.append(EXAM_RECORD_SQL);
|
|
|
- sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
- sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 1))");
|
|
|
- sqlBuilder.append(" group by record_data.id ");
|
|
|
- //根据ip查询
|
|
|
- /*if (StringUtils.isNoneBlank(query.getIp())) {
|
|
|
- sqlBuilder.append(" having ip like '%"+query.getIp()+"%' ");
|
|
|
- }*/
|
|
|
- sqlBuilder.append(" order by record_data.id desc");
|
|
|
-
|
|
|
- List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(sqlBuilder.toString(), new RowMapper<ExamRecordDataEntity>() {
|
|
|
- @Override
|
|
|
- public ExamRecordDataEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
- return getExamRecordDataEntityByResultSet(rs);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- List<ExamRecordInfo> examRecordInfoList = examRecordEntityConvert.of(examRecordDataList);
|
|
|
- return this.loadExamRecordDetailData(examRecordInfoList, query.getExamId());
|
|
|
- }
|
|
|
-
|
|
|
- private List<ExamRecordInfo> loadExamRecordDetailData(List<ExamRecordInfo> list, Long examId) {
|
|
|
- if (list == null || list.size() == 0) {
|
|
|
- return new ArrayList<ExamRecordInfo>();
|
|
|
- }
|
|
|
- //缓存
|
|
|
- Map<String, Object> cahcheMap = new HashMap<String, Object>();
|
|
|
-
|
|
|
- list.forEach(examRecordInfo -> {
|
|
|
- //获取考试名称
|
|
|
- ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
|
|
|
- examRecordInfo.setExamName(examBean.getName());
|
|
|
-
|
|
|
- ExamStudentInfo examStudent = (ExamStudentInfo) cahcheMap.get("examStudentinfo_" + examRecordInfo.getExamStudentId());
|
|
|
- if (examStudent == null) {
|
|
|
- examStudent = examStudentService.getExamStudentInfo(examRecordInfo.getExamStudentId());
|
|
|
- cahcheMap.put("examStudentinfo_" + examRecordInfo.getExamStudentId(), examStudent);
|
|
|
- }
|
|
|
-
|
|
|
- String photoNumber = localCacheService.getStudentPhotoNumber(cahcheMap, examRecordInfo.getStudentId());
|
|
|
- examRecordInfo.setPhone(photoNumber);//电话号码
|
|
|
- if (examStudent != null) {
|
|
|
- examRecordInfo.setSpecialtyName(examStudent.getSpecialtyName());
|
|
|
- examRecordInfo.setGrade(examStudent.getGrade());
|
|
|
- }
|
|
|
- Map<String, String> data = this.getPaperScore(examRecordInfo.getDataId());
|
|
|
- //试卷总分
|
|
|
- examRecordInfo.setPaperTotalScore(data.get("paperTotalScore"));
|
|
|
- //客观题总分
|
|
|
- examRecordInfo.setObjectiveTotalScore(data.get("objectiveTotalScore"));
|
|
|
- //主观题总分
|
|
|
- examRecordInfo.setSubjectiveTotalScore(data.get("subjectiveTotalScore"));
|
|
|
- });
|
|
|
- return list;
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public List<ExamRecordInfo> getExamRecordDetailList(ExamRecordQuery query) {
|
|
|
+// Check.isNull(query, "查询参数不能为空!");
|
|
|
+// query.addRecordStatus(ExamRecordStatus.EXAM_END.name());
|
|
|
+// query.addRecordStatus(ExamRecordStatus.EXAM_OVERDUE.name());
|
|
|
+//
|
|
|
+// StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+// sqlBuilder.append(EXAM_RECORD_SQL);
|
|
|
+// sqlBuilder.append(buildExamRecordCommonSelectCondition(query));
|
|
|
+// sqlBuilder.append(" and ((record_data.is_warn = 0) OR (record_data.is_warn = 1 and record_data.is_audit = 1))");
|
|
|
+// sqlBuilder.append(" group by record_data.id ");
|
|
|
+// //根据ip查询
|
|
|
+// /*if (StringUtils.isNoneBlank(query.getIp())) {
|
|
|
+// sqlBuilder.append(" having ip like '%"+query.getIp()+"%' ");
|
|
|
+// }*/
|
|
|
+// sqlBuilder.append(" order by record_data.id desc");
|
|
|
+//
|
|
|
+// List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(sqlBuilder.toString(), new RowMapper<ExamRecordDataEntity>() {
|
|
|
+// @Override
|
|
|
+// public ExamRecordDataEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
+// return getExamRecordDataEntityByResultSet(rs);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// List<ExamRecordInfo> examRecordInfoList = examRecordEntityConvert.of(examRecordDataList);
|
|
|
+// return this.loadExamRecordDetailData(examRecordInfoList, query.getExamId());
|
|
|
+// }
|
|
|
+
|
|
|
+// private List<ExamRecordInfo> loadExamRecordDetailData(List<ExamRecordInfo> list, Long examId) {
|
|
|
+// if (list == null || list.size() == 0) {
|
|
|
+// return new ArrayList<ExamRecordInfo>();
|
|
|
+// }
|
|
|
+// //缓存
|
|
|
+// Map<String, Object> cahcheMap = new HashMap<String, Object>();
|
|
|
+//
|
|
|
+// list.forEach(examRecordInfo -> {
|
|
|
+// //获取考试名称
|
|
|
+// ExamSettingsCacheBean examBean = ExamCacheTransferHelper.getDefaultCachedExam(examId);
|
|
|
+// examRecordInfo.setExamName(examBean.getName());
|
|
|
+//
|
|
|
+// ExamStudentInfo examStudent = (ExamStudentInfo) cahcheMap.get("examStudentinfo_" + examRecordInfo.getExamStudentId());
|
|
|
+// if (examStudent == null) {
|
|
|
+// examStudent = examStudentService.getExamStudentInfo(examRecordInfo.getExamStudentId());
|
|
|
+// cahcheMap.put("examStudentinfo_" + examRecordInfo.getExamStudentId(), examStudent);
|
|
|
+// }
|
|
|
+//
|
|
|
+// String photoNumber = localCacheService.getStudentPhotoNumber(cahcheMap, examRecordInfo.getStudentId());
|
|
|
+// examRecordInfo.setPhone(photoNumber);//电话号码
|
|
|
+// if (examStudent != null) {
|
|
|
+// examRecordInfo.setSpecialtyName(examStudent.getSpecialtyName());
|
|
|
+// examRecordInfo.setGrade(examStudent.getGrade());
|
|
|
+// }
|
|
|
+// Map<String, String> data = this.getPaperScore(examRecordInfo.getDataId());
|
|
|
+// //试卷总分
|
|
|
+// examRecordInfo.setPaperTotalScore(data.get("paperTotalScore"));
|
|
|
+// //客观题总分
|
|
|
+// examRecordInfo.setObjectiveTotalScore(data.get("objectiveTotalScore"));
|
|
|
+// //主观题总分
|
|
|
+// examRecordInfo.setSubjectiveTotalScore(data.get("subjectiveTotalScore"));
|
|
|
+// });
|
|
|
+// return list;
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public List<ExamStudentQuestionScoreInfo> getExamStudentQuestionScoreList(Long examId, String courseCode) {
|