|
@@ -0,0 +1,119 @@
|
|
|
+package cn.com.qmth.examcloud.core.oe.admin.service.impl;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.base.jpa.SpecUtils;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.base.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordIllegallyService;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.UserDataRules;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditInfo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.ExamAuditQuery;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+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;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ExamRecordIllegallyServiceImpl implements ExamRecordIllegallyService {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ExamRecordIllegallyServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ExamAuditInfo> getExamRecordIllegallyList(UserDataRules rules, ExamAuditQuery query) {
|
|
|
+ Check.isNull(query, "请求参数不能为空!");
|
|
|
+ Check.isNull(query.getExamId(), "请先选择考试!");
|
|
|
+
|
|
|
+ Pageable pageable = SpecUtils.buildPageable(query.getPageNo(), query.getPageSize());
|
|
|
+ int offset = (query.getPageNo() - 1) * query.getPageSize();
|
|
|
+
|
|
|
+ String countSql = this.queryExamRecordIllegallyListSql(query, true);
|
|
|
+ String querySql = this.queryExamRecordIllegallyListSql(query, false);
|
|
|
+ String pageSql = querySql + " limit " + offset + "," + query.getPageSize();
|
|
|
+
|
|
|
+ Long totalElements = jdbcTemplate.queryForObject(countSql, Long.class);
|
|
|
+ if (totalElements == null || totalElements == 0) {
|
|
|
+ return new PageImpl<>(new ArrayList<>(), pageable, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExamAuditInfo> list = jdbcTemplate.query(pageSql, new BeanPropertyRowMapper(ExamAuditInfo.class));
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return new PageImpl<>(new ArrayList<>(), pageable, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PageImpl<>(list, pageable, totalElements);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String queryExamRecordIllegallyListSql(ExamAuditQuery query, boolean isCount) {
|
|
|
+ StringBuilder sql = new StringBuilder();
|
|
|
+ if (isCount) {
|
|
|
+ sql.append(" select count(1)");
|
|
|
+ } else {
|
|
|
+ sql.append(" select rd.id AS examRecordDataId,rd.exam_id,rd.exam_type,");
|
|
|
+ sql.append(" rd.course_id,rd.org_id,rd.exam_stage_id,rd.student_id,");
|
|
|
+ sql.append(" rd.exam_student_id,rd.student_code,rd.student_name,rd.identity_number,");
|
|
|
+ sql.append(" rd.start_time AS paperStartTime,rd.end_time AS paperSubmitTime,rd.exam_order,");
|
|
|
+ sql.append(" rd.face_total_count,rd.face_success_count,rd.face_failed_count,");
|
|
|
+ sql.append(" rd.face_success_percent,rd.face_stranger_count,rd.face_verify_result,");
|
|
|
+ sql.append(" rd.switch_screen_count,sco.objective_score,a.id,a.status,ill.name AS discipline_type,");
|
|
|
+ sql.append(" a.discipline_detail,a.audit_user_name,a.update_time AS paperAuditTime,");
|
|
|
+ sql.append(" (select GROUP_CONCAT(DISTINCT pr.source_ip) from ec_oe_exam_process_record pr")
|
|
|
+ .append(" where pr.exam_record_data_id = rd.id) ip");
|
|
|
+ }
|
|
|
+
|
|
|
+ sql.append(" from ec_oe_exam_record_data rd ");
|
|
|
+ sql.append(" left join ec_oe_exam_audit a on a.exam_record_data_id = rd.id");
|
|
|
+ sql.append(" left join ec_oe_illegally_type ill on ill.code = a.discipline_type")
|
|
|
+ .append(" and (ill.root_org_id = -1 or ill.root_org_id = rd.root_org_id)");
|
|
|
+ sql.append(" left join ec_oe_exam_score sco on sco.exam_record_data_id = rd.id");
|
|
|
+
|
|
|
+ sql.append(" where rd.exam_id = ").append(query.getExamId());
|
|
|
+ sql.append(" and rd.exam_record_status != 'EXAM_INVALID'");
|
|
|
+ sql.append(" and exists (");
|
|
|
+ sql.append(" select aa.exam_record_data_id from ec_oe_exam_audit aa");
|
|
|
+ sql.append(" where aa.exam_record_data_id = rd.id and aa.status = 'UN_PASS'");
|
|
|
+ if (StringUtils.isNotBlank(query.getDisciplineType())) {
|
|
|
+ sql.append(" and aa.discipline_type = '").append(query.getDisciplineType()).append("'");
|
|
|
+ }
|
|
|
+ sql.append(" )");
|
|
|
+
|
|
|
+ if (query.getCourseId() != null) {
|
|
|
+ sql.append(" and rd.course_id = ").append(query.getCourseId());
|
|
|
+ }
|
|
|
+ if (query.getOrgId() != null) {
|
|
|
+ sql.append(" and rd.org_id = ").append(query.getOrgId());
|
|
|
+ }
|
|
|
+ if (query.getExamStageId() != null) {
|
|
|
+ sql.append(" and rd.exam_stage_id = ").append(query.getExamStageId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(query.getCourseLevel())) {
|
|
|
+ sql.append(" and rd.course_level = '").append(query.getCourseLevel()).append("'");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(query.getIdentityNumber())) {
|
|
|
+ sql.append(" and rd.identity_number like '").append(query.getIdentityNumber()).append("%'");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(query.getStudentCode())) {
|
|
|
+ sql.append(" and rd.student_code like '").append(query.getStudentCode()).append("%'");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(query.getStudentName())) {
|
|
|
+ sql.append(" and rd.student_name like '").append(query.getStudentName()).append("%'");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isCount) {
|
|
|
+ sql.append(" order by rd.update_time desc");
|
|
|
+ }
|
|
|
+
|
|
|
+ return sql.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|