Pārlūkot izejas kodu

examSummary_finishCount修改

wangliang 1 gadu atpakaļ
vecāks
revīzija
893eba13f0

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamSummaryMapper.java

@@ -24,6 +24,15 @@ public interface TEExamSummaryMapper extends BaseMapper<TEExamSummary> {
      */
     TEExamSummary examSummary(@Param("examId") Long examId, @Param("examActivityId") Long examActivityId, @Param("roomCode") String roomCode);
 
+    /**
+     * 更新考试完成数
+     *
+     * @param examId
+     * @param examActivityId
+     * @param roomCode
+     */
+    void updateExamSummaryFinishCount(Long examId, Long examActivityId, String roomCode);
+
     /**
      * 保存统计考试信息
      *

+ 0 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TEExamSummary.java

@@ -72,8 +72,6 @@ public class TEExamSummary implements Serializable {
     @ApiModelProperty(value = "异常数据总数")
     private Integer exceptionCount = 0;
 
-
-
     public Long getId() {
         return id;
     }

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamSummaryService.java

@@ -25,4 +25,13 @@ public interface TEExamSummaryService extends IService<TEExamSummary> {
      * @return
      */
     boolean examSummary(Long examId, Long examActivityId, Set<String> roomCodeSet, boolean freshen);
+
+    /**
+     * 更新考试完成数
+     *
+     * @param examId
+     * @param examActivityId
+     * @param roomCode
+     */
+    void updateExamSummaryFinishCount(Long examId, Long examActivityId, String roomCode);
 }

+ 14 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamSummaryServiceImpl.java

@@ -73,6 +73,18 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
         return updateCache;
     }
 
+    /**
+     * 更新考试完成数
+     *
+     * @param examId
+     * @param examActivityId
+     * @param roomCode
+     */
+    @Override
+    public void updateExamSummaryFinishCount(Long examId, Long examActivityId, String roomCode) {
+        this.baseMapper.updateExamSummaryFinishCount(examId, examActivityId, roomCode);
+    }
+
     /**
      * 考试计算公用
      *
@@ -94,8 +106,6 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
                 Integer absentCount = teExamStudentService.getAbsentCount(examId, examActivityId, s);
                 teExamSummary.setAbsentCount(Objects.nonNull(absentCount) ? absentCount : 0);
             }
-//            Integer finishCount = tOeExamRecordService.findExamRecordByFinish(examId, examActivityId, s);
-//            teExamSummary.setFinishCount(finishCount);
             TEExamSummary teExamSummaryDb = this.getOne(new QueryWrapper<TEExamSummary>().lambda()
                     .eq(TEExamSummary::getExamId, examId)
                     .eq(TEExamSummary::getExamActivityId, examActivityId)
@@ -106,8 +116,10 @@ public class TEExamSummaryServiceImpl extends ServiceImpl<TEExamSummaryMapper, T
                 teExamSummaryDb.setId(UidUtil.nextId());
             } else {
                 Long id = teExamSummaryDb.getId();
+                Integer finishCount = teExamSummaryDb.getFinishCount();
                 BeanUtils.copyProperties(teExamSummary, teExamSummaryDb);
                 teExamSummaryDb.setId(id);
+                teExamSummaryDb.setFinishCount(finishCount);
             }
             this.saveOrUpdate(teExamSummaryDb);
             themisCacheService.updateExamSummaryCache(examId, examActivityId, s);

+ 8 - 3
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeExamRecordServiceImpl.java

@@ -118,6 +118,9 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
     @Resource
     TMTencentVideoMessageService tmTencentVideoMessageService;
 
+    @Resource
+    TEExamSummaryService teExamSummaryService;
+
     @Transactional
     @Override
     public TOeExamRecord saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId,
@@ -427,19 +430,21 @@ public class TOeExamRecordServiceImpl extends ServiceImpl<TOeExamRecordMapper, T
             }
             //更新考生信息
             teExamStudentService.updateExamStudentByCache(er.getExamStudentId());
-            ExamStudentCacheBean examStudentCache = (ExamStudentCacheBean) redisUtil.get(RedisKeyHelper.examStudentCacheKey(er.getExamStudentId()));
+            ExamStudentCacheBean examStudentCache = teExamStudentService.getExamStudentCacheBean(er.getExamStudentId());
             ExamCacheBean examCacheBean = examService.getExamCacheBean(ExamRecordCacheUtil.getExamId(recordId));
+            Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
             if (Objects.nonNull(examStudentCache.getAlreadyExamCount()) &&
                     examStudentCache.getAlreadyExamCount().longValue() == 1) {
                 teOrgSummaryService.updateOrgZeroSummary(examCacheBean.getOrgId(), 1);
                 teOrgSummaryService.updateOrgZeroSummary(0L, 1);
+                teExamSummaryService.updateExamSummaryFinishCount(examCacheBean.getId(), examActivityId, examStudentCache.getRoomCode());
             } else {
                 teOrgSummaryService.updateOrgZeroSummary(examCacheBean.getOrgId(), 0);
                 teOrgSummaryService.updateOrgZeroSummary(0L, 0);
             }
             themisCacheService.updateOrgSummaryCache(0L);
-
-            Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+            themisCacheService.updateOrgSummaryCache(examCacheBean.getOrgId());
+            themisCacheService.updateExamSummaryCache(examCacheBean.getId(), examActivityId, examStudentCache.getRoomCode());
             String examRecordChangeKey = examActivityId + "_" + examStudentCache.getRoomCode();
             themisCacheService.addExamRecordChangeCache(examRecordChangeKey, timestamp);
 

+ 18 - 2
themis-business/src/main/resources/mapper/TEExamSummaryMapper.xml

@@ -13,8 +13,9 @@
             sum(t.warning_count) as warningCount,
             sum(t.warning_unread) as warningUnread,
             sum(t.warning_multiple_face_count) as warningMultipleFaceCount,
-            sum(t.exception_count) as exceptionCount,
-            sum(case when ((t.status = 'FINISHED' or t.status = 'PERSISTED' and t.first_start_time is not null) or s.already_exam_count > 0) then 1 else 0 end) as finishCount
+            sum(t.exception_count) as exceptionCount
+               <!--,
+            sum(case when ((t.status = 'FINISHED' or t.status = 'PERSISTED' and t.first_start_time is not null) or s.already_exam_count > 0) then 1 else 0 end) as finishCount-->
         from t_e_exam_student s
             left join t_oe_exam_record t on t.id = s.current_record_id
         <where> 1 = 1
@@ -36,6 +37,21 @@
         VALUES(${fieldValue})
     </insert>
 
+    <update id="updateExamSummaryFinishCount">
+        update t_e_exam_summary set finish_count = finish_count + 1
+        <where> 1 = 1
+            <if test="examId != null and examId != ''">
+                and exam_id = #{examId}
+            </if>
+            <if test="examActivityId != null and examActivityId != ''">
+                and exam_activity_id = #{examActivityId}
+            </if>
+            <if test="roomCode != null and roomCode != ''">
+                and room_code = #{roomCode}
+            </if>
+        </where>
+    </update>
+
     <update id="updateExamSummary">
         update t_e_exam_summary
         set ${fieldValue}

+ 2 - 1
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -1919,7 +1919,7 @@
     <select id="findExamRecordByFinish" resultType="java.lang.Integer">
         select count(distinct t.exam_student_id) from t_oe_exam_record t
         left join t_e_exam_student tees on tees.id = t.exam_student_id
-        <where>1 = 1
+        <where> 1 = 1
             <if test="examId != null and examId != ''">
                 and t.id = #{examId}
             </if>
@@ -1929,6 +1929,7 @@
             <if test="roomCode != null and roomCode != ''">
                 and tees.room_code = #{roomCode}
             </if>
+                and (t.status = 'FINISHED' or t.status = 'PERSISTED') and t.first_start_time is not null
         </where>
     </select>
 </mapper>