Quellcode durchsuchen

巡考监考优化

wangliang vor 3 Jahren
Ursprung
Commit
dca0411be2

+ 3 - 20
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -453,28 +453,11 @@ public class TEExamController {
         examPropCountDto.get().setExamId(examId);
         if (Objects.nonNull(roomCodeSet) && roomCodeSet.size() > 0) {
             //根据roomCode获取当前老师所要监考的全部应考学生数
-            QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
-            teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getExamId, examId)
-                    .in(TEExamStudent::getRoomCode, roomCodeSet);
-            List<TEExamStudent> teExamStudentList = new ArrayList<>(50000);
-            teExamStudentList = teExamStudentService.list(teExamStudentQueryWrapper);
-            if (Objects.nonNull(teExamStudentList) && teExamStudentList.size() > 0) {
-                examPropCountDto.get().setAllCount(teExamStudentList.size());
-            }
-
             List<CountStopBean> countStopBeanList = tOeExamRecordService.findByStopInfo(examId, roomCodeSet);
             if (Objects.nonNull(countStopBeanList) && countStopBeanList.size() > 0) {
-                AtomicReference<Integer> clientWebsocketStatusCount = new AtomicReference<>(0);
-                AtomicReference<Integer> monitorStatusSourceCount = new AtomicReference<>(0);
-                for (CountStopBean c : countStopBeanList) {
-                    clientWebsocketStatusCount.getAndSet(clientWebsocketStatusCount.get() + c.getClientWebsocketStatusOffCount());
-                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + c.getCameraMonitorStatusStop());
-                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + c.getScreenMonitorStatusStop());
-                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + c.getMobileFirstMonitorStatusStop());
-                    monitorStatusSourceCount.getAndSet(monitorStatusSourceCount.get() + c.getMobileSecondMonitorStatusStop());
-                }
-                examPropCountDto.get().setClientWebsocketStatusCount(clientWebsocketStatusCount.get());
-                examPropCountDto.get().setMonitorStatusSourceCount(monitorStatusSourceCount.get());
+                examPropCountDto.get().setClientWebsocketStatusCount(countStopBeanList.get(0).getOffCount());
+                examPropCountDto.get().setMonitorStatusSourceCount(countStopBeanList.get(0).getStopCount());
+                examPropCountDto.get().setAllCount(countStopBeanList.get(0).getAllCount());
             }
             List<Integer> list = tOeExamRecordService.findByOnlineInfo(examId, roomCodeSet);
             if (Objects.nonNull(list) && list.size() > 0) {

+ 17 - 50
themis-business/src/main/java/com/qmth/themis/business/bean/admin/CountStopBean.java

@@ -14,68 +14,35 @@ import java.io.Serializable;
 public class CountStopBean implements Serializable {
 
     @ApiModelProperty(name = "客户端websocket不在线")
-    private Integer clientWebsocketStatusOffCount;
+    private Integer offCount;
 
-    @ApiModelProperty(name = "客户端websocket在线")
-    private Integer clientWebsocketStatusOnCount;
+    @ApiModelProperty(name = "推流状态")
+    private Integer stopCount;
 
-    @ApiModelProperty(name = "客户端摄像头状态")
-    private Integer cameraMonitorStatusStop;
+    @ApiModelProperty(name = "应考人数")
+    private Integer allCount;
 
-    @ApiModelProperty(name = "客户端屏幕状态")
-    private Integer screenMonitorStatusStop;
-
-    @ApiModelProperty(name = "移动端第一机位状态")
-    private Integer mobileFirstMonitorStatusStop;
-
-    @ApiModelProperty(name = "移动端第二机位状态")
-    private Integer mobileSecondMonitorStatusStop;
-
-    public Integer getClientWebsocketStatusOffCount() {
-        return clientWebsocketStatusOffCount;
-    }
-
-    public void setClientWebsocketStatusOffCount(Integer clientWebsocketStatusOffCount) {
-        this.clientWebsocketStatusOffCount = clientWebsocketStatusOffCount;
-    }
-
-    public Integer getClientWebsocketStatusOnCount() {
-        return clientWebsocketStatusOnCount;
-    }
-
-    public void setClientWebsocketStatusOnCount(Integer clientWebsocketStatusOnCount) {
-        this.clientWebsocketStatusOnCount = clientWebsocketStatusOnCount;
-    }
-
-    public Integer getCameraMonitorStatusStop() {
-        return cameraMonitorStatusStop;
-    }
-
-    public void setCameraMonitorStatusStop(Integer cameraMonitorStatusStop) {
-        this.cameraMonitorStatusStop = cameraMonitorStatusStop;
-    }
-
-    public Integer getScreenMonitorStatusStop() {
-        return screenMonitorStatusStop;
+    public Integer getOffCount() {
+        return offCount;
     }
 
-    public void setScreenMonitorStatusStop(Integer screenMonitorStatusStop) {
-        this.screenMonitorStatusStop = screenMonitorStatusStop;
+    public void setOffCount(Integer offCount) {
+        this.offCount = offCount;
     }
 
-    public Integer getMobileFirstMonitorStatusStop() {
-        return mobileFirstMonitorStatusStop;
+    public Integer getStopCount() {
+        return stopCount;
     }
 
-    public void setMobileFirstMonitorStatusStop(Integer mobileFirstMonitorStatusStop) {
-        this.mobileFirstMonitorStatusStop = mobileFirstMonitorStatusStop;
+    public void setStopCount(Integer stopCount) {
+        this.stopCount = stopCount;
     }
 
-    public Integer getMobileSecondMonitorStatusStop() {
-        return mobileSecondMonitorStatusStop;
+    public Integer getAllCount() {
+        return allCount;
     }
 
-    public void setMobileSecondMonitorStatusStop(Integer mobileSecondMonitorStatusStop) {
-        this.mobileSecondMonitorStatusStop = mobileSecondMonitorStatusStop;
+    public void setAllCount(Integer allCount) {
+        this.allCount = allCount;
     }
 }

+ 40 - 28
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -918,15 +918,11 @@
         select count(1) as c
         from t_oe_exam_record toer
         where exists(
-                select teea.id
-                from t_e_exam_activity teea
-                where exists(
-                        select tee.id
-                        from t_e_exam tee
-                        where tee.org_id = #{orgId}
-                          and tee.id = teea.exam_id
-                    )
-                  and toer.exam_activity_id = teea.id)
+                select tee.id
+                from t_e_exam tee
+                where tee.org_id = 89389883529379840
+                  and toer.exam_id = tee.id
+            )
           and (toer.STATUS = 'FIRST_PREPARE'
             or toer.STATUS = 'ANSWERING'
             or toer.STATUS = 'BREAK_OFF'
@@ -936,43 +932,42 @@
         select count(1) as c
         from t_oe_exam_record toer
         where exists(
-                select teea.id
-                from t_e_exam_activity teea
-                where exists(
-                        select tee.id
-                        from t_e_exam tee
-                        where tee.org_id = #{orgId}
-                          and tee.id = teea.exam_id
-                    )
-                  and toer.exam_activity_id = teea.id)
+                select tee.id
+                from t_e_exam tee
+                where tee.org_id = 89389883529379840
+                  and toer.exam_id = tee.id
+            )
           and toer.STATUS = 'FIRST_PREPARE'
           and toer.client_websocket_status = 'ON_LINE'
         union all
         select count(1) as c
         from t_oe_exam_record toer
         where exists(
-                select teea.id
-                from t_e_exam_activity teea
-                where exists(
-                        select tee.id
-                        from t_e_exam tee
-                        where tee.org_id = #{orgId}
-                          and tee.id = teea.exam_id
-                    )
-                  and toer.exam_activity_id = teea.id)
+                select tee.id
+                from t_e_exam tee
+                where tee.org_id = 89389883529379840
+                  and toer.exam_id = tee.id
+            )
           and toer.STATUS = 'ANSWERING'
           and toer.client_websocket_status = 'ON_LINE'
     </select>
 
     <select id="findByStopInfo" resultType="com.qmth.themis.business.bean.admin.CountStopBean">
         select
+        sum(t.clientWebsocketStatusOffCount) as offCount,
+        sum(t.cameraMonitorStatusStop + t.screenMonitorStatusStop + t.mobileFirstMonitorStatusStop +
+        t.mobileSecondMonitorStatusStop) as stopCount,
+        sum(t.allCount) as allCount
+        from
+        (select
         count((t.client_websocket_status = 'OFF_LINE' or t.client_websocket_status is null) or null) as
         clientWebsocketStatusOffCount,
         count(t.client_websocket_status = 'ON_LINE') as clientWebsocketStatusOnCount,
         count(t.camera_monitor_status = 'STOP') as cameraMonitorStatusStop,
         count(t.screen_monitor_status = 'STOP') as screenMonitorStatusStop,
         count(t.mobile_first_monitor_status = 'STOP') as mobileFirstMonitorStatusStop,
-        count(t.mobile_second_monitor_status = 'STOP') as mobileSecondMonitorStatusStop
+        count(t.mobile_second_monitor_status = 'STOP') as mobileSecondMonitorStatusStop,
+        0 as allCount
         from
         t_oe_exam_record t
         left join t_e_exam_student s on
@@ -997,6 +992,23 @@
         t.screen_monitor_status,
         t.mobile_first_monitor_status,
         t.mobile_second_monitor_status
+        UNION all
+        select
+        0 as clientWebsocketStatusOffCount,
+        0 as clientWebsocketStatusOnCount,
+        0 as cameraMonitorStatusStop,
+        0 as screenMonitorStatusStop,
+        0 as mobileFirstMonitorStatusStop,
+        0 as mobileSecondMonitorStatusStop,
+        count(1) as allCount
+        from
+        t_e_exam_student t
+        where
+        t.exam_id = #{examId}
+        and t.room_code in
+        <foreach collection="roomCodeSet" item="roomCode" index="index" open="(" close=")" separator=",">
+            #{roomCode}
+        </foreach>) t
     </select>
 
     <select id="findByOnlineInfo" resultType="java.lang.Integer">