|
@@ -1,12 +1,12 @@
|
|
|
package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamRecordDataRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.ExamScoreRepo;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamScoreEntity;
|
|
|
-import cn.com.qmth.examcloud.core.oe.admin.dao.enums.ExamRecordStatus;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.dao.enums.MarkingType;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordService;
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.bean.ExamStudentEffectiveScoreInfo;
|
|
@@ -41,151 +41,84 @@ public class ExamRecordServiceImpl implements ExamRecordService {
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- /**
|
|
|
- * 构建查询 考试明细sql语句
|
|
|
- *
|
|
|
- * @param query
|
|
|
- * @return
|
|
|
- */
|
|
|
- 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());
|
|
|
- }
|
|
|
- if (query.getSwitchScreenCountEnd() != null) {
|
|
|
- sql.append(" and record_data.switch_screen_count <= " + query.getSwitchScreenCountEnd());
|
|
|
- }
|
|
|
- if (query.getExamRecordDataId() != null) {
|
|
|
- sql.append(" and record_data.id = " + query.getExamRecordDataId());
|
|
|
- }
|
|
|
- if (query.getOrgId() != null) {
|
|
|
- sql.append(" and record_data.org_id = " + query.getOrgId());
|
|
|
- }
|
|
|
- if (query.getExamId() != null) {
|
|
|
- sql.append(" and record_data.exam_id = " + query.getExamId());
|
|
|
+ @Override
|
|
|
+ public List<ExamRecordDataEntity> getExamRecordListByExamStudentId(Long examStudentId) {
|
|
|
+ Check.isNull(examStudentId, "考生ID不能为空!");
|
|
|
+ return examRecordDataRepo.findByExamStudentId(examStudentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long existsWarnExamRecordDetail(UserDataRules uds, ExamRecordQuery query) {
|
|
|
+ Check.isNull(query, "请求参数不能为空!");
|
|
|
+ Check.isNull(query.getExamId(), "请先选择考试!");
|
|
|
+
|
|
|
+ UserDataRule courseRule = uds.getCourseRule();
|
|
|
+ UserDataRule orgRule = uds.getOrgRule();
|
|
|
+ if (courseRule.assertEmptyQueryResult() || orgRule.assertEmptyQueryResult()) {
|
|
|
+ return 0L;
|
|
|
}
|
|
|
+
|
|
|
+ StringBuilder sql = new StringBuilder();
|
|
|
+ sql.append(" select count(rd.id) from ec_oe_exam_record_data rd");
|
|
|
+ sql.append(" where rd.exam_id = ").append(query.getExamId());
|
|
|
+ sql.append(" and rd.exam_record_status in ('EXAM_END','EXAM_OVERDUE')");
|
|
|
+ sql.append(" and rd.is_warn = 1 and rd.is_audit = 0");
|
|
|
+
|
|
|
if (query.getExamStageId() != null) {
|
|
|
- sql.append(" and record_data.exam_stage_id = " + query.getExamStageId());
|
|
|
+ sql.append(" and rd.exam_stage_id = " + query.getExamStageId());
|
|
|
}
|
|
|
-
|
|
|
if (StringUtils.isNotBlank(query.getStudentCode())) {
|
|
|
- sql.append(" and record_data.student_code LIKE '" + query.getStudentCode() + "%'");
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(query.getStudentName())) {
|
|
|
- sql.append(" and record_data.student_name LIKE '" + query.getStudentName() + "%'");
|
|
|
+ sql.append(" and rd.student_code like '" + query.getStudentCode() + "%'");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(query.getIdentityNumber())) {
|
|
|
- sql.append(" and record_data.identity_number LIKE '" + query.getIdentityNumber() + "%'");
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(query.getInfoCollector())) {
|
|
|
- sql.append(" and record_data.info_collector LIKE '" + query.getInfoCollector() + "%'");
|
|
|
+ sql.append(" and rd.identity_number like '" + query.getIdentityNumber() + "%'");
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(query.getAuditUserName())) {
|
|
|
- sql.append(" and audit.audit_user_name LIKE '" + query.getAuditUserName() + "%'");
|
|
|
- }
|
|
|
- if (query.getCourseId() != null) {
|
|
|
- sql.append(" and record_data.course_id = " + query.getCourseId());
|
|
|
+ if (StringUtils.isNotBlank(query.getStudentName())) {
|
|
|
+ sql.append(" and rd.student_name like '" + query.getStudentName() + "%'");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(query.getCourseLevel())) {
|
|
|
- sql.append(" and record_data.course_level = '" + query.getCourseLevel() + "'");
|
|
|
- }
|
|
|
- if (query.getExamRecordId() != null) {
|
|
|
- sql.append(" and record_data.id = " + query.getExamRecordId());
|
|
|
- }
|
|
|
- if (query.getIsIllegality() != null) {
|
|
|
- if (query.getIsIllegality()) {
|
|
|
- sql.append(" and record_data.is_illegality = 1");
|
|
|
+ sql.append(" and rd.course_level = '" + query.getCourseLevel() + "'");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (courseRule.assertNeedQueryRefIds()) {
|
|
|
+ // 限定课程数据权限范围
|
|
|
+ if (query.getCourseId() != null) {
|
|
|
+ if (courseRule.getRefIds().contains(query.getCourseId())) {
|
|
|
+ sql.append(" and rd.course_id = ").append(query.getCourseId());
|
|
|
+ } else {
|
|
|
+ // 不在数据权限范围内,无效查询
|
|
|
+ sql.append(" and rd.course_id = -1");
|
|
|
+ }
|
|
|
} else {
|
|
|
- sql.append(" and record_data.is_illegality = 0");
|
|
|
+ sql.append(" and rd.course_id in (").append(StringUtils.join(courseRule.getRefIds(), ",")).append(")");
|
|
|
}
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(query.getStartTime()) && StringUtils.isNotBlank(query.getEndTime())) {
|
|
|
- sql.append(" and record_data.start_time >= str_to_date('" + query.getStartTime() + "','%Y/%m/%d %H:%i:%s')"
|
|
|
- + " and record_data.start_time <= str_to_date('" + query.getEndTime() + "','%Y/%m/%d %H:%i:%s')");
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(query.getSubmitStartTime()) && StringUtils.isNotBlank(query.getSubmitEndTime())) {
|
|
|
- sql.append(" and record_data.end_time is not null and record_data.end_time >= str_to_date('" + query.getSubmitStartTime() + "','%Y/%m/%d %H:%i:%s')"
|
|
|
- + " and record_data.end_time <= str_to_date('" + query.getSubmitEndTime() + "','%Y/%m/%d %H:%i:%s')");
|
|
|
- }
|
|
|
-
|
|
|
- //考试记录状态
|
|
|
- List<ExamRecordStatus> statusList = query.getRecordStatusList();
|
|
|
- if (statusList != null && statusList.size() > 0) {
|
|
|
- String status = "";
|
|
|
- for (int i = 0; i < statusList.size(); i++) {
|
|
|
- status += "'" + statusList.get(i) + "',";
|
|
|
- }
|
|
|
- status = status.substring(0, status.lastIndexOf(","));
|
|
|
- sql.append(" and record_data.exam_record_status IN (" + status + ")");
|
|
|
- }
|
|
|
- //是否有陌生人脸
|
|
|
- if (query.getHasStranger() != null) {
|
|
|
- if (query.getHasStranger()) {
|
|
|
- sql.append(" and record_data.face_stranger_count > 0");
|
|
|
- } else {
|
|
|
- sql.append(" and record_data.face_stranger_count = 0");
|
|
|
+ } else {
|
|
|
+ // 未限定数据权限
|
|
|
+ if (query.getCourseId() != null) {
|
|
|
+ sql.append(" and rd.course_id = ").append(query.getCourseId());
|
|
|
}
|
|
|
}
|
|
|
- //人脸识别成功率
|
|
|
- if (query.getFaceSuccessPercentLower() != null && query.getFaceSuccessPercentUpper() != null) {
|
|
|
- sql.append(" and record_data.face_success_percent >=" + query.getFaceSuccessPercentLower());
|
|
|
- sql.append(" and record_data.face_success_percent <=" + query.getFaceSuccessPercentUpper());
|
|
|
- }
|
|
|
- if (query.getLivenessSuccessPercentLower() != null && query.getLivenessSuccessPercentUpper() != null) {
|
|
|
- sql.append(" and record_data.baidu_face_liveness_success_percent >=" + query.getLivenessSuccessPercentLower());
|
|
|
- sql.append(" and record_data.baidu_face_liveness_success_percent <=" + query.getLivenessSuccessPercentUpper());
|
|
|
- }
|
|
|
|
|
|
- //是否有虚拟设备
|
|
|
- if (query.getHasVirtual() != null) {
|
|
|
- if (query.getHasVirtual()) {
|
|
|
- sql.append(" AND EXISTS( ");
|
|
|
- sql.append(" select 1 from ec_oe_exam_capture_camera_info v where record_data.id = v.exam_record_data_id and v.virtual_camera=1 ");
|
|
|
- sql.append(" ) ");
|
|
|
+ if (orgRule.assertNeedQueryRefIds()) {
|
|
|
+ // 限定机构数据权限范围
|
|
|
+ if (query.getOrgId() != null) {
|
|
|
+ if (orgRule.getRefIds().contains(query.getOrgId())) {
|
|
|
+ sql.append(" and rd.org_id = ").append(query.getOrgId());
|
|
|
+ } else {
|
|
|
+ // 不在数据权限范围内,无效查询
|
|
|
+ sql.append(" and rd.org_id = -1");
|
|
|
+ }
|
|
|
} else {
|
|
|
- sql.append(" AND NOT EXISTS( ");
|
|
|
- sql.append(" select 1 from ec_oe_exam_capture_camera_info v where record_data.id = v.exam_record_data_id and v.virtual_camera=1 ");
|
|
|
- sql.append(" ) ");
|
|
|
+ sql.append(" and rd.org_id in (").append(StringUtils.join(orgRule.getRefIds(), ",")).append(")");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 未限定数据权限
|
|
|
+ if (query.getOrgId() != null) {
|
|
|
+ sql.append(" and rd.org_id = ").append(query.getOrgId());
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(query.getVirtualName())) {
|
|
|
- sql.append(" AND EXISTS( ");
|
|
|
- sql.append(" select 1 from ec_oe_exam_capture_camera_info ci where record_data.id = ci.exam_record_data_id ");
|
|
|
- sql.append(" and ci.virtual_camera=1 and ci.name='" + query.getVirtualName() + "' ");
|
|
|
- sql.append(" ) ");
|
|
|
- }
|
|
|
-
|
|
|
- //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;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<ExamRecordDataEntity> getExamRecordListByExamStudentId(Long examStudentId) {
|
|
|
- Check.isNull(examStudentId, "考生ID不能为空!");
|
|
|
- return examRecordDataRepo.findByExamStudentId(examStudentId);
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- 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(uds, query));
|
|
|
- sqlBuilder.append(" and record_data.is_warn = 1 and record_data.is_audit = 0");
|
|
|
- return jdbcTemplate.queryForObject(sqlBuilder.toString(), Long.class);
|
|
|
+ return jdbcTemplate.queryForObject(sql.toString(), Long.class);
|
|
|
}
|
|
|
|
|
|
@Override
|