Pārlūkot izejas kodu

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

# Conflicts:
#	themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java
#	themis-business/src/main/resources/mapper/TEExamStudentMapper.xml
wangliang 4 gadi atpakaļ
vecāks
revīzija
e75cf704ac

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

@@ -44,4 +44,18 @@ public class TIeReportController {
                              @ApiParam(value = "唯一码", required = false) @RequestParam String identity) {
         return ResultUtil.ok(reportService.examView(examId, examActivityId, roomCode, courseCode, name, identity));
     }
+    
+    @ApiOperation(value = "情况统计")
+    @RequestMapping(value = "/exam_view_count", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "结果信息")})
+    public Result examViewCount(@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,
+                             @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+                             @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        return ResultUtil.ok(reportService.examViewCount(examId, examActivityId, roomCode, courseCode, name, identity,pageNumber,pageSize));
+    }
 }

+ 105 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/backend/ExamViewCountListBean.java

@@ -0,0 +1,105 @@
+package com.qmth.themis.business.bean.backend;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel("报表-情况统计返回对象")
+public class ExamViewCountListBean implements Serializable {
+
+    /**
+	 * 
+	 */
+	private static final long serialVersionUID = -4399923396400174947L;
+	
+	@ApiModelProperty(name = "考试名称")
+    private String examName;
+	
+	@ApiModelProperty(name = "考试id")
+    private Long examId;
+
+    @ApiModelProperty(name = "场次id")
+    private Long examActivityId;
+
+    @ApiModelProperty(name = "虚拟考场代码")
+    private String roomCode;
+
+    @ApiModelProperty(name = "虚拟考场名称")
+    private String roomName;
+
+    @ApiModelProperty(name = "应考")
+    private Long examTotal;
+    
+    @ApiModelProperty(name = "实考")
+    private Long actualExamTotal;
+    
+    @ApiModelProperty(name = "缺考")
+    private Long deficiencyExamTotal;
+
+	public String getExamName() {
+		return examName;
+	}
+
+	public void setExamName(String examName) {
+		this.examName = examName;
+	}
+
+	public Long getExamId() {
+		return examId;
+	}
+
+	public void setExamId(Long examId) {
+		this.examId = examId;
+	}
+
+	public Long getExamActivityId() {
+		return examActivityId;
+	}
+
+	public void setExamActivityId(Long examActivityId) {
+		this.examActivityId = examActivityId;
+	}
+
+	public String getRoomCode() {
+		return roomCode;
+	}
+
+	public void setRoomCode(String roomCode) {
+		this.roomCode = roomCode;
+	}
+
+	public String getRoomName() {
+		return roomName;
+	}
+
+	public void setRoomName(String roomName) {
+		this.roomName = roomName;
+	}
+
+	public Long getExamTotal() {
+		return examTotal;
+	}
+
+	public void setExamTotal(Long examTotal) {
+		this.examTotal = examTotal;
+	}
+
+	public Long getActualExamTotal() {
+		return actualExamTotal;
+	}
+
+	public void setActualExamTotal(Long actualExamTotal) {
+		this.actualExamTotal = actualExamTotal;
+	}
+
+	public Long getDeficiencyExamTotal() {
+		return deficiencyExamTotal;
+	}
+
+	public void setDeficiencyExamTotal(Long deficiencyExamTotal) {
+		this.deficiencyExamTotal = deficiencyExamTotal;
+	}
+
+    
+}

+ 14 - 13
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -1,15 +1,16 @@
 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.RoomCodeQueryDto;
+import com.qmth.themis.business.bean.backend.ExamViewCountListBean;
 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.List;
-import java.util.Map;
 
 /**
  * @Description: 考生库 Mapper 接口
@@ -44,11 +45,11 @@ public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
     public List<Map<String, Object>> getTotalCount(@Param("examId") Long examId, @Param("activityId") Long activityId,
                                                    @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);
 
-    /**
-     * 考场查询
-     *
-     * @param roomName
-     * @return
-     */
-    public List<RoomCodeQueryDto> examRoomQuery(@Param("roomName") String roomName);
+	public IPage<ExamViewCountListBean> getTotalCountInfo(IPage<Map> iPage,@Param("examId") Long examId, @Param("activityId") Long activityId,
+                                                   @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);
+	
+	public List<Map<String,Object>> getDoneCountByActivityIds(@Param("examId") Long examId,@Param("activityIds") List<Long> activityIds);
+	
+	public List<Map<String,Object>> getAbsentCountByActivityIds(@Param("examId") Long examId,@Param("activityIds") List<Long> activityIds);
+	
 }

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

@@ -245,4 +245,5 @@ public interface TOeExamRecordMapper extends BaseMapper<TOeExamRecord> {
 	
 	public List<Map<String,Object>> getDoneCountByDay(@Param("examId") Long examId, @Param("activityId") Long activityId,
 			@Param("roomCode") String roomCode,@Param("courseCode")  String courseCode);
+	
 }

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

@@ -2,7 +2,12 @@ package com.qmth.themis.business.service;
 
 import java.util.Map;
 
+import com.qmth.themis.business.base.BasePage;
+
 public interface TIeReportService {
 	public Map<String, Object> examView(Long examId, Long examActivityId, String roomCode, String courseCode,
 			String name, String identity);
+
+	public BasePage examViewCount(Long examId, Long examActivityId, String roomCode, String courseCode, String name,
+			String identity, int pageNumber, int pageSize);
 }

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

@@ -1,18 +1,26 @@
 package com.qmth.themis.business.service.impl;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
 import org.springframework.stereotype.Service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.themis.business.base.BasePage;
+import com.qmth.themis.business.bean.backend.ExamViewCountListBean;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
+import com.qmth.themis.business.cache.bean.ExamCacheBean;
 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.TEExamService;
 import com.qmth.themis.business.service.TIeReportService;
 
 @Service
@@ -26,6 +34,9 @@ public class TIeReportServiceImpl implements TIeReportService {
     
     @Resource
     TEExamActivityService examActivityService;
+    
+    @Resource
+    TEExamService examService;
 
 	@Override
 	public Map<String, Object> examView(Long examId, Long examActivityId, String roomCode, String courseCode,
@@ -86,5 +97,66 @@ public class TIeReportServiceImpl implements TIeReportService {
 		return ret;
 	}
 
+	@Override
+	public BasePage examViewCount(Long examId, Long examActivityId, String roomCode, String courseCode, String name,
+			String identity, int pageNumber, int pageSize) {
+		//应考人数
+		IPage<ExamViewCountListBean> total = examStudentMapper.getTotalCountInfo(new Page<>(pageNumber, pageSize),examId, examActivityId, roomCode, courseCode);
+        List<ExamViewCountListBean> data=total.getRecords();
+        BasePage basePage = new BasePage(total.getRecords(), total.getCurrent(), total.getSize(), total.getTotal());
+        if(data==null||data.size()==0) {
+        	return basePage;
+        }
+        List<Long> activityIds=data.stream().map(e -> e.getExamActivityId()).collect(Collectors.toList());
+        
+        //实考
+        List<Map<String,Object>> doneCountByDay=examStudentMapper.getDoneCountByActivityIds(examId, activityIds);
+		Map<String,Long> doneMap=new HashMap<String,Long>();
+		for(Map<String,Object> map:doneCountByDay) {
+			Long acId=(Long)map.get("activityId");
+			String roomcode=(String)map.get("roomCode");
+			Long count=(Long)map.get("cc");
+			doneMap.put(acId+"-"+roomcode, count);
+		}
+		
+		//缺考
+		List<Long> absentActivityIds=new ArrayList<>();
+		Date now = new Date();
+		for(Long acid:activityIds) {
+			ExamActivityCacheBean ac=examActivityService.getExamActivityCacheBean(acid);
+			Long end = ac.getStartTime().getTime() + (ac.getOpeningSeconds() * 1000);
+	        if (now.getTime() > end) {//场次开考时间结束,未开考的都是缺考
+	        	absentActivityIds.add(acid);
+	        }
+		}
+		
+		Map<String,Long> absentMap=new HashMap<String,Long>();
+		if(absentActivityIds.size()>0) {
+			List<Map<String,Object>> absentCountByDay=examStudentMapper.getAbsentCountByActivityIds(examId, absentActivityIds);
+			for(Map<String,Object> map:absentCountByDay) {
+				Long acId=(Long)map.get("activityId");
+				String roomcode=(String)map.get("roomCode");
+				Long count=(Long)map.get("cc");
+				absentMap.put(acId+"-"+roomcode, count);
+			}
+		}
+		ExamCacheBean exam=examService.getExamCacheBean(examId);
+		for(ExamViewCountListBean b:data) {
+			Long done=doneMap.get(b.getExamActivityId()+"-"+b.getRoomCode());
+			if(done==null) {
+				done=0L;
+			}
+			Long absent=absentMap.get(b.getExamActivityId()+"-"+b.getRoomCode());
+			if(absent==null) {
+				absent=0L;
+			}
+			b.setActualExamTotal(done);
+			b.setDeficiencyExamTotal(absent);
+			b.setExamName(exam.getName());
+		}
+		basePage = new BasePage(total.getRecords(), total.getCurrent(), total.getSize(), total.getTotal());
+		return basePage;
+	}
+
 
 }

+ 38 - 12
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -71,18 +71,44 @@
             </if>
          group by t.exam_activity_id
     </select>
-
-    <select id="examRoomQuery" resultType="com.qmth.themis.business.dto.response.RoomCodeQueryDto">
-        select
-        DISTINCT
-        tees.room_code as roomCode,
-        tees.room_name as roomName
-        from
-        t_e_exam_student tees
-        <where>
-            <if test="roomName != null and roomName != ''">
-                and tees.room_name like concat('%', #{roomName}, '%')
+    
+    <select id="getTotalCountInfo" resultType="com.qmth.themis.business.bean.backend.ExamViewCountListBean">
+    	select t.exam_id examId,t.exam_activity_id examActivityId,t.room_code roomCode,t.room_name roomName, count(1) examTotal from t_e_exam_student t
+    	where  t.exam_id = #{examId}
+            <if test="activityId != null and activityId != ''">
+                and t.exam_activity_id = #{activityId}
             </if>
-        </where>
+            <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_id,t.exam_activity_id, t.room_code,t.room_name
+    </select>
+    
+    <select id="getDoneCountByActivityIds" resultType="java.util.Map">
+    	select t.exam_activity_id activityId,t.room_code roomCode,count(1) cc from t_e_exam_student t
+    	where  t.exam_id = #{examId} and t.current_record_id is not null
+        <if test="activityIds != null">
+            and t.exam_activity_id in 
+            <foreach collection="activityIds" item="acid" index="index" open="(" close=")" separator=",">
+		    	#{acid}
+		   	</foreach>
+        </if>
+        group by t.exam_activity_id, t.room_code
+    </select>
+    
+    <select id="getAbsentCountByActivityIds" resultType="java.util.Map">
+    	select t.exam_activity_id activityId,t.room_code roomCode,count(1) cc from t_e_exam_student t
+    	where  t.exam_id = #{examId} and t.current_record_id is null
+        <if test="activityIds != null">
+            and t.exam_activity_id in 
+            <foreach collection="activityIds" item="acid" index="index" open="(" close=")" separator=",">
+		    	#{acid}
+		   	</foreach>
+        </if>
+        group by t.exam_activity_id, t.room_code
     </select>
+    
 </mapper>