Browse Source

merge from release_v4.0.2

deason 4 years ago
parent
commit
10a02a9253

+ 15 - 24
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/SyncExamDataCloudServiceProvider.java

@@ -17,10 +17,8 @@ import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
 import cn.com.qmth.examcloud.support.cache.CacheHelper;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
-import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
 import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
-import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
@@ -37,8 +35,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * @Description 同步考试相关数据接口
@@ -95,6 +91,8 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
     private ExamContinuedRecordRepo examContinuedRecordRepo;
     @Autowired
     private ExamProcessRecordRepo examProcessRecordRepo;
+    @Autowired
+    private RedisClient redisClient;
 
     /**
      * 同步考试记录数据
@@ -173,6 +171,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
 
         //同步抓拍照片结果(异步抓拍的数据)
         if (null != req.getExamCaptures()) {
+
             syncExamCapture(req.getExamCaptures(), realExamRecordDataId);
         }
 
@@ -208,10 +207,15 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         if (FaceBiopsyHelper.isFaceEnable(transitionExamRecordData.getRootOrgId(), transitionExamRecordData.getExamId(), transitionExamRecordData.getStudentId())) {
             //计算违纪自动审核结果(无人脸或活检失败)
             boolean isNoPhotoAndIllegality = (null == req.getExamCaptures() || req.getExamCaptures().isEmpty());//是否无照片
-
             saveAutoAudit(transitionExamRecordData, isNoPhotoAndIllegality, realExamRecordDataId);
         }
 
+        //header校验错误
+        Boolean hasWarn = redisClient.get("OE_SESSION_WARN_"+transitionExamRecordDataId, Boolean.class);
+        if(hasWarn !=null && hasWarn){
+            examAuditService.saveHeaderWarnAudit(realExamRecordDataId);
+        }
+
         startTime = this.debugCost("13 如果开启了活检,计算违纪自动审核结果", transitionExamRecordDataId, startTime);
 
         //同步后续处理
@@ -225,6 +229,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         return new SyncExamDataResp();
     }
 
+
     private void syncExamContinuedRecords(List<ExamContinuedRecordBean> examContinuedRecords, Long realExamRecordDataId) {
         for (ExamContinuedRecordBean bean : examContinuedRecords) {
             ExamContinuedRecordEntity entity = copyExamContinuedRecordFrom(bean, realExamRecordDataId);
@@ -436,8 +441,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
     }
 
     private void saveAutoAudit(ExamRecordDataBean examRecordData, boolean isNoPhotoAndIllegality, Long realExamRecordDataId) {
-        //是否已自动审核
-        boolean isAutoAudit = false;
+        boolean isAutoAudit = false;//是否已自动审核
         //无照片违纪自动审核
         if (isNoPhotoAndIllegality) {
             examAuditService.saveExamAuditByNoPhoto(realExamRecordDataId);
@@ -445,7 +449,8 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         } else {
             //活体检测失败违纪自动审核
             if (null != examRecordData.getFaceVerifyResult()
-                    && IsSuccess.FAILED.name().equals(examRecordData.getFaceVerifyResult())) {
+                    && IsSuccess.FAILED.name().equals(examRecordData.getFaceVerifyResult())
+                    && examRecordData.getIllegality()) {
                 examAuditService.saveExamAuditByFaceVerifyFailed(realExamRecordDataId, examRecordData.getRootOrgId());
                 isAutoAudit = true;
             }
@@ -642,14 +647,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         entity.setFacelivenessResult(examSyncCapture.getFacelivenessResult());
         entity.setProcessTime(examSyncCapture.getProcessTime());
         entity.setHasVirtualCamera(examSyncCapture.getHasVirtualCamera());
-
-        String cameraInfos = examSyncCapture.getCameraInfos();
-        if(StringUtils.isNotBlank(cameraInfos) && cameraInfos.length()>=800){
-            cameraInfos = "[{\"name\":\"虚拟摄像头信息超长!\",\"pid\":\"\",\"vid\":\"\"}]";
-            log.error("虚拟摄像头信息超长!");
-        }
-
-        entity.setCameraInfos(cameraInfos);
+        entity.setCameraInfos(examSyncCapture.getCameraInfos());
         entity.setExtMsg(examSyncCapture.getExtMsg());
 
         return entity;
@@ -675,14 +673,7 @@ public class SyncExamDataCloudServiceProvider extends ControllerSupport implemen
         entity.setFacelivenessResult(examCapture.getFacelivenessResult());
         entity.setProcessTime(examCapture.getProcessTime());
         entity.setHasVirtualCamera(examCapture.getHasVirtualCamera());
-
-        String cameraInfos = examCapture.getCameraInfos();
-        if(StringUtils.isNotBlank(cameraInfos) && cameraInfos.length()>=800){
-            cameraInfos = "[{\"name\":\"虚拟摄像头信息超长!\",\"pid\":\"\",\"vid\":\"\"}]";
-            log.error("虚拟摄像头信息超长!");
-        }
-
-        entity.setCameraInfos(cameraInfos);
+        entity.setCameraInfos(examCapture.getCameraInfos());
         entity.setExtMsg(examCapture.getExtMsg());
 
         return entity;

+ 2 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamAuditService.java

@@ -12,6 +12,7 @@ import java.util.List;
 import org.springframework.data.domain.Page;
 
 import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamAuditEntity;
+import cn.com.qmth.examcloud.core.oe.admin.dao.enums.DisciplineType;
 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 cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.RedoAuditInfo;
@@ -85,4 +86,5 @@ public interface ExamAuditService {
      */
     void saveExamAuditByNoPhoto(Long examRecordDataId);
 
+    void saveHeaderWarnAudit(Long realExamRecordDataId);
 }

+ 24 - 10
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamAuditServiceImpl.java

@@ -9,6 +9,7 @@ package cn.com.qmth.examcloud.core.oe.admin.service.impl;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
 import cn.com.qmth.examcloud.core.oe.admin.base.jpa.Searcher;
 import cn.com.qmth.examcloud.core.oe.admin.base.jpa.SpecUtils;
 import cn.com.qmth.examcloud.core.oe.admin.base.jpa.SqlWrapper;
@@ -19,6 +20,7 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.*;
 import cn.com.qmth.examcloud.core.oe.admin.dao.enums.*;
 import cn.com.qmth.examcloud.core.oe.admin.service.*;
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.examaudit.*;
+import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
 import cn.com.qmth.examcloud.marking.api.MarkWorkCloudService;
 import cn.com.qmth.examcloud.marking.api.request.AppendMarkWorkPaperReq;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
@@ -94,7 +96,6 @@ public class ExamAuditServiceImpl implements ExamAuditService {
 
     @Autowired
     ExamStudentFinalScoreRepo examStudentFinalScoreRepo;
-
     /**
      * 活体检测失败自动审核
      */
@@ -176,18 +177,12 @@ public class ExamAuditServiceImpl implements ExamAuditService {
             wrapper.and().lte("audit.update_time", query.getAuditEndTime());
         }
 
-        //查询分页记录
-        wrapper.groupBy("record.id ");
-        //根据ip查询
-        if (StringUtils.isNoneBlank(query.getIp())) {
-            wrapper.having().like("ip",query.getIp());
-        }
-        //需求调整20200816:按审核时间排序
-        wrapper.orderBy("record.update_time", true);
         long totalSize = 0;
         //查询总记录数
         if (query.getSelectType() == null || query.getSelectType() != SelectType.EXPORT) {
-            String countSql = "SELECT count(1) FROM ("+wrapper.build()+") t";
+            final String count = "count(0)";
+            final String leftJoin = "LEFT JOIN ec_oe_exam_process_record AS process ON record.id = process.exam_record_data_id";
+            String countSql = wrapper.build().replace(columns, count).replace(leftJoin," ");
             Query countQuery = entityManager.createNativeQuery(countSql);
             BigInteger element = (BigInteger) countQuery.getSingleResult();
             totalSize = element.longValue();
@@ -196,6 +191,9 @@ public class ExamAuditServiceImpl implements ExamAuditService {
             }
         }
 
+        wrapper.groupBy("record.id ");
+        //查询分页记录
+        wrapper.orderBy("record.update_time", true);//需求调整20200816:按审核时间排序
         Query dataQuery = entityManager.createNativeQuery(wrapper.build());
 
 //        dataQuery.unwrap(SQLQuery.class).setResultTransformer(Transformers.aliasToBean(HashMap.class));
@@ -398,6 +396,22 @@ public class ExamAuditServiceImpl implements ExamAuditService {
         examAuditRepo.save(examAuditEntity);
     }
 
+    @Override
+    public void saveHeaderWarnAudit(Long realExamRecordDataId) {
+        ExamAuditEntity examAudit = examAuditRepo.findByExamRecordDataId(realExamRecordDataId);
+        if (examAudit != null) {
+            return;
+        }
+        ExamAuditEntity examAuditEntity = new ExamAuditEntity();
+        examAuditEntity.setExamRecordDataId(realExamRecordDataId);
+        examAuditEntity.setDisciplineType("ILLEGAL_DATA");
+        examAuditEntity.setDisciplineDetail("非法数据");
+        examAuditEntity.setUserId("ILLEGAL_DATA");
+        examAuditEntity.setAuditUserName(AUDIT_USER_NAME);
+        examAuditEntity.setStatus(AuditStatus.UN_PASS);
+        examAuditRepo.save(examAuditEntity);
+    }
+
     //获取活检违纪详情
     private String getFaceVerifyDisciplineDetail(Long examRecordDataId, Long rootOrgId) {
         FaceBiopsyScheme faceBiopsyScheme = FaceBiopsyHelper.getFaceBiopsyScheme(rootOrgId);

+ 14 - 9
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordServiceImpl.java

@@ -296,21 +296,26 @@ public class ExamRecordServiceImpl implements ExamRecordService {
      * @return
      */
     private Page<ExamRecordInfo> _getExamRecordDetailListForPage(ExamRecordQuery query) {
+        //分页条件
+        int currentNum = (query.getPageNo() - 1) * query.getPageSize();
         Check.isNull(query, "查询参数不能为空!");
         //查询条件
         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))");
+        StringBuilder condition = buildExamRecordCommonSelectCondition(query);
+        sqlBuilder.append(condition);
+        String otherCondition = " and ((record_data.is_warn = 0) OR (record_data.is_warn  = 1 and record_data.is_audit = 1))";
+        sqlBuilder.append(otherCondition);
+        String idBuilder = "select id from ec_oe_exam_record_data record_data where 1 = 1" + condition + otherCondition+
+                " order by record_data.id desc limit " + currentNum + ",1 ";
+        sqlBuilder.append(" and record_data.id <=(").append(idBuilder).append(")");
         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());
+        sqlBuilder.append(" limit " + query.getPageSize());
         List<ExamRecordDataEntity> examRecordDataList = jdbcTemplate.query(sqlBuilder.toString(), new RowMapper<ExamRecordDataEntity>() {
             @Override
             public ExamRecordDataEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
@@ -845,9 +850,9 @@ public class ExamRecordServiceImpl implements ExamRecordService {
         sqlBuilder.append(" and record_data.id >"+startId);
         sqlBuilder.append(" group by record_data.id ");
         //根据ip查询
-        if (StringUtils.isNoneBlank(query.getIp())) {
+        /*if (StringUtils.isNoneBlank(query.getIp())) {
             sqlBuilder.append(" having ip like '%"+query.getIp()+"%' ");
-        }
+        }*/
         sqlBuilder.append(" order by record_data.id limit 500");
         
         RowMapper<ExamRecordInfo> rowMapper=new BeanPropertyRowMapper<ExamRecordInfo>(ExamRecordInfo.class);
@@ -867,9 +872,9 @@ public class ExamRecordServiceImpl implements ExamRecordService {
         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())) {
+        /*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>() {