Browse Source

考试统计方法

wangchangsheng 2 years ago
parent
commit
dcd1053feb

+ 49 - 7
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/controller/ExamController.java

@@ -6,18 +6,13 @@ import com.gyee.boot.base.api.annon.DataProtect;
 import com.gyee.boot.base.api.annon.LogInject;
 import com.gyee.boot.base.api.api.ApiRest;
 import com.gyee.boot.base.api.api.controller.BaseController;
-import com.gyee.boot.base.api.api.dto.BaseIdReqDTO;
-import com.gyee.boot.base.api.api.dto.BaseIdsReqDTO;
-import com.gyee.boot.base.api.api.dto.BaseStateReqDTO;
-import com.gyee.boot.base.api.api.dto.PagingReqDTO;
+import com.gyee.boot.base.api.api.dto.*;
 import com.gyee.boot.base.api.utils.BeanMapper;
 import com.gyee.boot.base.aspect.log.enums.LogType;
 import com.gyee.exam.modules.exam.dto.ExamDTO;
 import com.gyee.exam.modules.exam.dto.request.ExamReqDTO;
 import com.gyee.exam.modules.exam.dto.request.ExamSaveReqDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamCheckRespDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamOnlineRespDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamReviewRespDTO;
+import com.gyee.exam.modules.exam.dto.response.*;
 import com.gyee.exam.modules.exam.entity.Exam;
 import com.gyee.exam.modules.exam.service.ExamService;
 import io.swagger.annotations.Api;
@@ -28,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.List;
 
 /**
 * <p>
@@ -181,4 +177,50 @@ public class ExamController extends BaseController {
         respDTO.setPassword("");
         return super.success(respDTO);
     }
+
+    /**
+     * 各部门考试及格率
+     * @return
+     */
+    @ApiOperation(value = "部门考试及格率")
+    @GetMapping("/depart-passed-rate")
+    public ApiRest departPassedRate(@RequestBody BaseQueryReqDTO reqDTO) {
+
+        List<ExamDepartPassedRateDTO> dtoList = baseService.departPassedRate(reqDTO);
+        return super.success(dtoList);
+    }
+
+
+    /**
+     * 各职员考试及格率
+     * @return
+     */
+    @ApiOperation(value = "用户考试及格率")
+    @GetMapping("/user-passed-rate")
+    public ApiRest userPassedRate(@RequestBody BaseQueryReqDTO reqDTO) {
+
+        List<ExamUserPassedRateDTO> dtoList = baseService.userPassedRate(reqDTO);
+        return super.success(dtoList);
+
+    }
+
+
+
+
+    /**
+     * 部门培训统计
+     * @return
+     */
+    @ApiOperation(value = "部门培训统计")
+    @GetMapping("/exam-depart-total")
+    public ApiRest examDepartTotal(@RequestBody BaseQueryReqDTO reqDTO) {
+
+        List<ExamDepartTotalDTO> dtoList = baseService.examDepartTotal(reqDTO);
+        return super.success(dtoList);
+
+    }
+
+
+
+
 }

+ 26 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/dto/response/ExamDepartPassedRateDTO.java

@@ -0,0 +1,26 @@
+package com.gyee.exam.modules.exam.dto.response;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value="考试及格率统计响应类", description="考试及格率统计响应类")
+public class ExamDepartPassedRateDTO {
+
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "部门编码")
+    private String deptCode;
+
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "参加考试总人次")
+    private Integer total;
+
+    @ApiModelProperty(value = "参加考试通过人数")
+    private double passed;
+}

+ 32 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/dto/response/ExamDepartTotalDTO.java

@@ -0,0 +1,32 @@
+package com.gyee.exam.modules.exam.dto.response;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value="考试统计响应类", description="考试统计响应类")
+public class ExamDepartTotalDTO {
+
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "部门编码")
+    private String deptCode;
+
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "考试总人次")
+    private Integer eeTotalUser;
+
+    @ApiModelProperty(value = "考试人次")
+    private Integer eeActualUser;
+
+    @ApiModelProperty(value = "已考试结束人数")
+    private Integer eePassUser;
+
+
+
+}

+ 25 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/dto/response/ExamUserPassedRateDTO.java

@@ -0,0 +1,25 @@
+package com.gyee.exam.modules.exam.dto.response;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+@Data
+@ApiModel(value="职员考试及格率统计响应类", description="职员考试及格率统计响应类")
+public class ExamUserPassedRateDTO {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "用户名")
+    private String userName;
+
+    @ApiModelProperty(value = "真实名称")
+    private String realName;
+
+    @ApiModelProperty(value = "参加考试总人次")
+    private Integer total;
+
+    @ApiModelProperty(value = "参加考试通过人数")
+    private double passed;
+}

+ 24 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/mapper/ExamDepartMapper.java

@@ -1,7 +1,14 @@
 package com.gyee.exam.modules.exam.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamDepartPassedRateDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamUserPassedRateDTO;
 import com.gyee.exam.modules.exam.entity.ExamDepart;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
 /**
 * <p>
 * 考试部门Mapper
@@ -12,4 +19,21 @@ import com.gyee.exam.modules.exam.entity.ExamDepart;
 */
 public interface ExamDepartMapper extends BaseMapper<ExamDepart> {
 
+
+    /**
+     * 根据部门统计考试及格率
+     * @param reqDTO
+     * @return
+     */
+    List<ExamDepartPassedRateDTO> departPassedRate(@Param("query") BaseQueryReqDTO reqDTO);
+
+
+    /**
+     * 职员考试及格率统计
+     * @param reqDTO
+     * @return
+     */
+    List<ExamUserPassedRateDTO> userPassedRate(@Param("query") BaseQueryReqDTO reqDTO);
+
+
 }

+ 12 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/mapper/ExamMapper.java

@@ -3,12 +3,16 @@ package com.gyee.exam.modules.exam.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
 import com.gyee.exam.modules.exam.dto.ExamDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamDepartTotalDTO;
 import com.gyee.exam.modules.exam.dto.response.ExamReviewRespDTO;
 import com.gyee.exam.modules.exam.dto.response.ExamOnlineRespDTO;
 import com.gyee.exam.modules.exam.entity.Exam;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
 * <p>
 * 考试Mapper
@@ -42,4 +46,12 @@ public interface ExamMapper extends BaseMapper<Exam> {
      * @return
      */
     IPage<ExamOnlineRespDTO> online(Page page, @Param("query") ExamDTO query);
+
+
+    /**
+     * 部门培训统计
+     * @param reqDTO
+     * @return
+     */
+    List<ExamDepartTotalDTO> examDepartTotal(@Param("query") BaseQueryReqDTO reqDTO);
 }

+ 26 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/service/ExamDepartService.java

@@ -1,7 +1,12 @@
 package com.gyee.exam.modules.exam.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamDepartPassedRateDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamDepartTotalDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamUserPassedRateDTO;
 import com.gyee.exam.modules.exam.entity.ExamDepart;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -29,4 +34,25 @@ public interface ExamDepartService extends IService<ExamDepart> {
      * @return
      */
     List<String> listByExam(String examId);
+
+    /**
+     * 更具部们统计考试及格率
+     * @param reqDTO
+     * @return
+     */
+    List<ExamDepartPassedRateDTO> departPassedRate(BaseQueryReqDTO reqDTO);
+
+
+    /**
+     * 职员考试及格率统计
+     * @param reqDTO
+     * @return
+     */
+    List<ExamUserPassedRateDTO> userPassedRate(BaseQueryReqDTO reqDTO);
+
+
+
+
+
+
 }

+ 25 - 3
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/service/ExamService.java

@@ -2,13 +2,12 @@ package com.gyee.exam.modules.exam.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
 import com.gyee.boot.base.api.api.dto.PagingReqDTO;
 import com.gyee.exam.modules.exam.dto.ExamDTO;
 import com.gyee.exam.modules.exam.dto.request.ExamReqDTO;
 import com.gyee.exam.modules.exam.dto.request.ExamSaveReqDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamCheckRespDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamOnlineRespDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamReviewRespDTO;
+import com.gyee.exam.modules.exam.dto.response.*;
 import com.gyee.exam.modules.exam.entity.Exam;
 
 import java.util.List;
@@ -85,4 +84,27 @@ public interface ExamService extends IService<Exam> {
      * @param ids
      */
     void delete(List<String> ids);
+
+    /**
+     * 部门考试及格率统计
+     * @param reqDTO
+     * @return
+     */
+    List<ExamDepartPassedRateDTO> departPassedRate(BaseQueryReqDTO reqDTO);
+
+    /**
+     * 职员考试及格率统计
+     * @param reqDTO
+     * @return
+     */
+    List<ExamUserPassedRateDTO> userPassedRate(BaseQueryReqDTO reqDTO);
+
+    /**
+     * 考试统计方法
+     * @param reqDTO
+     * @return
+     */
+    List<ExamDepartTotalDTO> examDepartTotal(BaseQueryReqDTO reqDTO);
+
+
 }

+ 17 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/service/impl/ExamDepartServiceImpl.java

@@ -2,7 +2,10 @@ package com.gyee.exam.modules.exam.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
 import com.gyee.boot.base.api.exception.ServiceException;
+import com.gyee.exam.modules.exam.dto.response.ExamDepartPassedRateDTO;
+import com.gyee.exam.modules.exam.dto.response.ExamUserPassedRateDTO;
 import com.gyee.exam.modules.exam.entity.ExamDepart;
 import com.gyee.exam.modules.exam.mapper.ExamDepartMapper;
 import com.gyee.exam.modules.exam.service.ExamDepartService;
@@ -63,4 +66,18 @@ public class ExamDepartServiceImpl extends ServiceImpl<ExamDepartMapper, ExamDep
         return ids;
 
     }
+
+    @Override
+    public List<ExamDepartPassedRateDTO> departPassedRate(BaseQueryReqDTO reqDTO) {
+        List<ExamDepartPassedRateDTO> dtos = baseMapper.departPassedRate(reqDTO);
+        return dtos;
+    }
+
+    @Override
+    public List<ExamUserPassedRateDTO> userPassedRate(BaseQueryReqDTO reqDTO) {
+        List<ExamUserPassedRateDTO>  dtos = baseMapper.userPassedRate(reqDTO);
+        return dtos;
+    }
+
+
 }

+ 26 - 3
exam-06173-api/src/main/java/com/gyee/exam/modules/exam/service/impl/ExamServiceImpl.java

@@ -4,18 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.boot.base.api.api.dto.BaseQueryReqDTO;
 import com.gyee.boot.base.api.api.dto.PagingReqDTO;
 import com.gyee.boot.base.api.exception.ServiceException;
 import com.gyee.boot.base.api.utils.BeanMapper;
+import com.gyee.exam.modules.exam.dto.response.*;
 import org.apache.commons.lang3.StringUtils;
 import com.gyee.exam.ability.redis.service.RedisService;
 import com.gyee.exam.enums.OpenType;
 import com.gyee.exam.modules.exam.dto.ExamDTO;
 import com.gyee.exam.modules.exam.dto.request.ExamReqDTO;
 import com.gyee.exam.modules.exam.dto.request.ExamSaveReqDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamCheckRespDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamOnlineRespDTO;
-import com.gyee.exam.modules.exam.dto.response.ExamReviewRespDTO;
 import com.gyee.exam.modules.exam.entity.Exam;
 import com.gyee.exam.modules.exam.mapper.ExamMapper;
 import com.gyee.exam.modules.exam.service.ExamDepartService;
@@ -217,4 +216,28 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements Ex
         return null;
     }
 
+
+    @Override
+    public List<ExamDepartPassedRateDTO> departPassedRate(BaseQueryReqDTO reqDTO) {
+        List<ExamDepartPassedRateDTO> dtos = examDepartService.departPassedRate(reqDTO);
+
+        return dtos;
+    }
+
+    @Override
+    public List<ExamUserPassedRateDTO> userPassedRate(BaseQueryReqDTO reqDTO) {
+        List<ExamUserPassedRateDTO> dtos  = examDepartService.userPassedRate(reqDTO);
+        return dtos;
+    }
+
+
+    @Override
+    public List<ExamDepartTotalDTO> examDepartTotal(BaseQueryReqDTO reqDTO) {
+
+        List<ExamDepartTotalDTO> dtos = baseMapper.examDepartTotal(reqDTO);
+
+        return dtos;
+    }
+
+
 }

+ 69 - 0
exam-06173-api/src/main/resources/mapper/exam/ExamDepartMapper.xml

@@ -14,4 +14,73 @@
         `id`,`exam_id`,`dept_code`
     </sql>
 
+    <select id="departPassedRate" resultType="com.gyee.exam.modules.exam.dto.response.ExamDepartPassedRateDTO">
+
+        SELECT  dept.dept_code deptCode,sd.dept_name deptName,
+        SUM((SELECT IFNULL(MAX(passed),0) FROM el_paper WHERE user_id=uc.id AND exam_id=dept.exam_id and passed >0)) AS passed,
+        count(dept.dept_code) total
+        FROM el_exam_depart dept
+        LEFT JOIN sys_user uc ON dept.dept_code=uc.dept_code
+        LEFT JOIN sys_depart sd on dept.dept_code = sd.dept_code
+        LEFT JOIN el_exam ee on ee.id = dept.exam_id
+        <where>
+
+            and uc.id IS NOT NULL
+
+            <if test="query!=null">
+
+                <if test="query.statDateL!=null ">
+                    AND ee.start_time >=    #{query.statDateL}
+                </if>
+
+                <if test="query.statDateR!=null ">
+                    AND ee.end_time &lt; #{query.statDateR}
+                </if>
+
+                <if test="query.q!=null and query.q!=''">
+                    AND dept.dept_code = #{query.q}
+                </if>
+
+            </if>
+
+        </where>
+        GROUP BY  dept.dept_code
+
+
+    </select>
+
+    <select id="userPassedRate" resultType="com.gyee.exam.modules.exam.dto.response.ExamUserPassedRateDTO">
+        SELECT  uc.user_name userName,uc.real_name realName,
+        SUM((SELECT IFNULL(MAX(passed),0) FROM el_paper WHERE user_id=uc.id AND exam_id=dept.exam_id and passed >0)) AS passed,
+        count(ee.id) total
+        FROM el_exam_depart dept
+        LEFT JOIN sys_user uc ON dept.dept_code=uc.dept_code
+        LEFT JOIN sys_depart sd on dept.dept_code = sd.dept_code
+        LEFT JOIN el_exam ee on ee.id = dept.exam_id
+        <where>
+            uc.id IS NOT NULL
+
+        </where>
+
+        <if test="query!=null">
+
+            <if test="query.statDateL!=null ">
+                AND ee.start_time >=    #{query.statDateL}
+            </if>
+
+            <if test="query.statDateR!=null ">
+                AND ee.end_time &lt; #{query.statDateR}
+            </if>
+
+            <if test="query.q!=null and query.q!=''">
+                AND dept.dept_code = #{query.q}
+            </if>
+
+        </if>
+
+        GROUP BY uc.user_name,uc.real_name order by passed desc
+
+
+    </select>
+
 </mapper>

+ 39 - 0
exam-06173-api/src/main/resources/mapper/exam/ExamMapper.xml

@@ -196,4 +196,43 @@
 
     </select>
 
+
+    <select id="examDepartTotal" resultType="com.gyee.exam.modules.exam.dto.response.ExamDepartTotalDTO">
+        SELECT
+        sd.dept_name deptName,
+        dept.dept_code deptCode,
+        COUNT(uc.id) AS eeTotalUser,
+        COUNT(DISTINCT ue.user_id) AS eeActualUser,
+        COUNT(IF( ue.passed = 1 ,1, NULL)) AS eePassUser
+        FROM el_exam ee
+        LEFT JOIN el_exam_depart dept on ee.id = dept.exam_id
+        LEFT JOIN sys_depart sd on sd.dept_code = dept.dept_code
+        LEFT JOIN sys_user uc ON dept.dept_code=uc.dept_code
+        LEFT JOIN el_user_exam ue ON ue.user_id=uc.id AND ue.exam_id=dept.exam_id
+        <where>
+
+            uc.id IS NOT NULL
+            <if test="query!=null">
+
+                <if test="query.statDateL!=null ">
+                    AND ee.start_time >=  #{query.statDateL}
+                </if>
+
+                <if test="query.statDateR!=null ">
+                    AND ee.end_time &lt; #{query.statDateR}
+                </if>
+
+                <if test="query.q!=null and query.q!=''">
+                    AND dept.dept_code = #{query.q}
+                </if>
+
+            </if>
+
+
+        </where>
+        GROUP BY dept.dept_code
+        ORDER BY eeActualUser desc ,eePassUser desc
+
+    </select>
+
 </mapper>