Преглед на файлове

Merge remote-tracking branch 'origin/dev' into dev

wangliang преди 4 години
родител
ревизия
eceb8410df

+ 47 - 0
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeReportController.java

@@ -0,0 +1,47 @@
+package com.qmth.themis.backend.api;
+
+import javax.annotation.Resource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.qmth.themis.business.service.TIeReportService;
+import com.qmth.themis.common.util.Result;
+import com.qmth.themis.common.util.ResultUtil;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+/** 监考报表
+ * @Description: 
+ * @Author: xiatian
+ * @Date: 2020-08-28
+ */
+@Api(tags = "监考报表")
+@RestController
+@RequestMapping("/${prefix.url.admin}/report")
+public class TIeReportController {
+    private final static Logger log = LoggerFactory.getLogger(TIeReportController.class);
+    
+    @Resource
+    private TIeReportService reportService;
+
+    @ApiOperation(value = "考试概览")
+    @RequestMapping(value = "/exam_view", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
+    public Result examView(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                             @ApiParam(value = "考场场次id", required = false) @RequestParam Long examActivityId,
+                             @ApiParam(value = "虚拟考场代码", required = false) @RequestParam String roomCode,
+                             @ApiParam(value = "科目编码", required = false) @RequestParam String courseCode,
+                             @ApiParam(value = "姓名", required = false) @RequestParam String name,
+                             @ApiParam(value = "唯一码", required = false) @RequestParam String identity) {
+        return ResultUtil.ok(reportService.examView(examId, examActivityId, roomCode, courseCode, name, identity));
+    }
+}

+ 1 - 1
themis-backend/src/main/resources/application.properties

@@ -164,4 +164,4 @@ prefix.url.admin=api/admin
 
 #\u65E0\u9700\u9274\u6743\u7684url
 no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/admin/monitor/call/list,/api/admin/monitor/call/query
-common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env,/api/admin/sys/file/upload,/api/admin/sys/file/download,/api/admin/sys/org/query,/api/admin/sys/role/query,/api/admin/sys/examActivity/query,/api/admin/sys/exam/query,/api/admin/sys/examRoom/query,/api/admin/student/photo/upload
+common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env,/api/admin/sys/file/upload,/api/admin/sys/file/download,/api/admin/sys/org/query,/api/admin/sys/role/query,/api/admin/sys/examActivity/query,/api/admin/sys/exam/query,/api/admin/sys/examRoom/query,/api/admin/student/photo/upload,/api/admin/report/exam_view

+ 27 - 19
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -1,13 +1,15 @@
 package com.qmth.themis.business.dao;
 
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.dto.response.TEExamStudentDto;
 import com.qmth.themis.business.entity.TEExamStudent;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.Map;
 
 /**
  * @Description: 考生库 Mapper 接口
@@ -19,19 +21,25 @@ import java.util.Map;
 @Mapper
 public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
 
-    /**
-     * 查询考生信息
-     *
-     * @param iPage
-     * @param examId
-     * @param activityId
-     * @param identity
-     * @param name
-     * @param roomCode
-     * @param courseCode
-     * @param grade
-     * @param enable
-     * @return
-     */
-    public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, @Param("examId") Long examId, @Param("activityId") Long activityId, @Param("identity") String identity, @Param("name") String name, @Param("roomCode") String roomCode, @Param("courseCode") String courseCode, @Param("grade") String grade, @Param("enable") Integer enable);
+	/**
+	 * 查询考生信息
+	 *
+	 * @param iPage
+	 * @param examId
+	 * @param activityId
+	 * @param identity
+	 * @param name
+	 * @param roomCode
+	 * @param courseCode
+	 * @param grade
+	 * @param enable
+	 * @return
+	 */
+	public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, @Param("examId") Long examId,
+			@Param("activityId") Long activityId, @Param("identity") String identity, @Param("name") String name,
+			@Param("roomCode") String roomCode, @Param("courseCode") String courseCode, @Param("grade") String grade,
+			@Param("enable") Integer enable);
+
+	public List<Map<String,Object>> getTotalCount(@Param("examId") Long examId, @Param("activityId") Long activityId,
+			@Param("roomCode") String roomCode,@Param("courseCode")  String courseCode);
 }

+ 7 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TOeExamRecordMapper.java

@@ -8,6 +8,7 @@ import com.qmth.themis.business.entity.TOeExamRecord;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -238,4 +239,10 @@ public interface TOeExamRecordMapper extends BaseMapper<TOeExamRecord> {
                                                                       @Param("clientWebsocketStatus") String clientWebsocketStatus,
                                                                       @Param("monitorStatusSource") String monitorStatusSource,
                                                                       @Param("userId") Long userId);
+    
+	public List<Map<String,Object>> getDoneCount(@Param("examId") Long examId, @Param("activityId") Long activityId,
+			@Param("roomCode") String roomCode,@Param("courseCode")  String courseCode);
+	
+	public List<Map<String,Object>> getDoneCountByDay(@Param("examId") Long examId, @Param("activityId") Long activityId,
+			@Param("roomCode") String roomCode,@Param("courseCode")  String courseCode);
 }

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TIeReportService.java

@@ -0,0 +1,8 @@
+package com.qmth.themis.business.service;
+
+import java.util.Map;
+
+public interface TIeReportService {
+	public Map<String, Object> examView(Long examId, Long examActivityId, String roomCode, String courseCode,
+			String name, String identity);
+}

+ 90 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TIeReportServiceImpl.java

@@ -0,0 +1,90 @@
+package com.qmth.themis.business.service.impl;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+
+import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
+import com.qmth.themis.business.dao.TEExamStudentMapper;
+import com.qmth.themis.business.dao.TOeExamRecordMapper;
+import com.qmth.themis.business.service.TEExamActivityService;
+import com.qmth.themis.business.service.TIeReportService;
+
+@Service
+public class TIeReportServiceImpl implements TIeReportService {
+	
+	@Resource
+	TEExamStudentMapper examStudentMapper;
+	
+    @Resource
+    TOeExamRecordMapper examRecordMapper;
+    
+    @Resource
+    TEExamActivityService examActivityService;
+
+	@Override
+	public Map<String, Object> examView(Long examId, Long examActivityId, String roomCode, String courseCode,
+			String name, String identity) {
+		//应考人数
+		Long totalNum=0L;
+		List<Map<String,Object>> total=examStudentMapper.getTotalCount(examId, examActivityId, roomCode, courseCode);
+		Map<Long,Long> totalMap=new HashMap<Long,Long>();
+		for(Map<String,Object> map:total) {
+			Long acId=(Long)map.get("activityId");
+			Long count=(Long)map.get("cc");
+			totalMap.put(acId, count);
+			totalNum=totalNum+count;
+		}
+		//实考人数
+		Long doneNum=0L;
+		List<Map<String,Object>> doneCount=examRecordMapper.getDoneCount(examId, examActivityId, roomCode, courseCode);
+		Map<Long,Long> doneMap=new HashMap<Long,Long>();
+		for(Map<String,Object> map:doneCount) {
+			Long acId=(Long)map.get("activityId");
+			if(acId!=null) {
+				Long count=(Long)map.get("cc");
+				doneMap.put(acId, count);
+				doneNum=doneNum+count;
+			}
+			
+		}
+		//缺考人数
+		Map<Long,Long> absentMap=new HashMap<Long,Long>();
+		Date now = new Date();
+		for(Long acId:totalMap.keySet()) {
+			ExamActivityCacheBean ac=examActivityService.getExamActivityCacheBean(acId);
+			Long end = ac.getStartTime().getTime() + (ac.getOpeningSeconds() * 1000);
+	        if (now.getTime() > end) {//场次开考时间结束,未开考的都是缺考
+	        	Long done=doneMap.get(acId);
+	        	if(done==null) {
+	        		done=0L;
+	        	}
+	        	absentMap.put(acId, totalMap.get(acId)-done);
+	        }
+		}
+		Long absentNum=0L;
+		if(absentMap.size()>0) {
+			for(Long c:absentMap.values()) {
+				absentNum=absentNum+c;
+			}
+		}
+		//每日已考人数
+		List<Map<String,Object>> doneCountByDay=examRecordMapper.getDoneCountByDay(examId, examActivityId, roomCode, courseCode);
+		
+		Map<String, Object> ret=new HashMap<String, Object>();
+		ret.put("examTotal", totalNum);
+		ret.put("actualExamTotal", doneNum);
+		ret.put("deficiencyExamTotal", absentNum);
+		ret.put("completeOffExamTotal", totalNum-doneNum-absentNum);
+		ret.put("examTotalList", doneCountByDay);
+		
+		return ret;
+	}
+
+
+}

+ 14 - 0
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -54,4 +54,18 @@
             </if>
         </where>
     </select>
+    <select id="getTotalCount" resultType="java.util.Map">
+    	select t.exam_activity_id activityId,count(1) cc from t_e_exam_student t
+    	where  t.exam_id = #{examId}
+            <if test="activityId != null and activityId != ''">
+                and t.exam_activity_id = #{activityId}
+            </if>
+            <if test="roomCode != null and roomCode != ''">
+                and t.room_code =#{roomCode}
+            </if>
+            <if test="courseCode != null and courseCode != ''">
+                and t.course_code = #{courseCode}
+            </if>
+         group by t.exam_activity_id
+    </select>
 </mapper>

+ 0 - 0
themis-business/src/main/resources/mapper/TOeExamRecordMapper.out.xml


+ 34 - 0
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -348,4 +348,38 @@
         </if>
         order by s.room_code
     </select>
+    
+    <select id="getDoneCount" resultType="java.util.Map">
+    	select f.exam_activity_id activityId,count(distinct(f.exam_student_id)) cc from t_oe_exam_record f
+    	left join t_e_exam_student t on f.exam_student_id=t.id
+    	where  f.exam_id = #{examId}
+            <if test="activityId != null and activityId != ''">
+                and f.exam_activity_id = #{activityId}
+            </if>
+            <if test="roomCode != null and roomCode != ''">
+                and t.room_code =#{roomCode}
+            </if>
+            <if test="courseCode != null and courseCode != ''">
+                and t.course_code = #{courseCode}
+            </if>
+            group by f.exam_activity_id
+    </select>
+    <select id="getDoneCountByDay" resultType="java.util.Map">
+    	select DATE_FORMAT(f.first_prepare_time, '%Y-%m-%d') AS day,
+		count(DISTINCT(f.exam_student_id)) count from t_oe_exam_record f
+    	left join t_e_exam_student t on f.exam_student_id=t.id
+    	where  f.exam_id = #{examId}
+            <if test="activityId != null and activityId != ''">
+                and f.exam_activity_id = #{activityId}
+            </if>
+            <if test="roomCode != null and roomCode != ''">
+                and t.room_code =#{roomCode}
+            </if>
+            <if test="courseCode != null and courseCode != ''">
+                and t.course_code = #{courseCode}
+            </if>
+            group by day
+            ORDER BY day
+    </select>
+    
 </mapper>