fix:考试总数

pg_adapter
wangxy 8 months ago
parent 9090ec8dc4
commit 8db276a4aa

@ -4,6 +4,7 @@ import com.ruoyi.system.domain.paper.dto.request.PaperListReqDTO;
import com.ruoyi.system.domain.paper.dto.response.PaperListRespDTO;
import com.ruoyi.system.domain.userexam.ElUserExam;
import com.ruoyi.system.domain.userexam.dto.request.UserExamReqDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamCountDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamRespDTO;
import com.ruoyi.system.service.ElPaperService;
import com.ruoyi.system.service.ElUserExamService;
@ -89,4 +90,10 @@ public class UserExamManager {
paperListReqDTO.setExamId(examId);
return paperService.paging(paperListReqDTO);
}
public UserExamCountDTO selectCountList() {
return elUserExamService.selectCountList();
}
}

@ -3,20 +3,18 @@ package com.ruoyi.web.controller.system.count;
import java.util.List;
import cn.hutool.core.convert.Convert;
import com.ruoyi.system.domain.userbook.dto.UserBookDTO;
import com.ruoyi.system.domain.userexam.dto.request.UserExamReqDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamExportDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamRespDTO;
import com.ruoyi.web.controller.manager.UserExamManager;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdExamnum;
@ -81,6 +79,14 @@ public class TdExamnumController extends BaseController
}
@ApiOperation("查找考试总数")
@PostMapping("/countList")
@ResponseBody
public AjaxResult countList() {
return AjaxResult.success(userExamManager.selectCountList());
}
}

@ -0,0 +1,34 @@
package com.ruoyi.system.domain.userexam.dto.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* packageName com.ruoyi.system.domain.userexam.dto.response
*
* @author wangxy
* @version JDK 8
* @className UserExamCountDTO
* @date 2024/8/7
* @description
*/
@Data
@ApiModel(value="考试统计", description="考试统计")
public class UserExamCountDTO implements Serializable {
@ApiModelProperty(value = "总数")
private Integer total;
@ApiModelProperty(value = "通过数")
private Integer tg;
@ApiModelProperty(value = "未通过数")
private Integer wtg;
}

@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.userexam.ElUserExam;
import com.ruoyi.system.domain.userexam.dto.request.UserExamReqDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamCountDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamRespDTO;
import org.apache.ibatis.annotations.Mapper;
@ -20,6 +21,9 @@ public interface ElUserExamMapper extends BaseMapper<ElUserExam> {
public List<UserExamRespDTO> selectExamList(UserExamReqDTO reqDTO);
public UserExamCountDTO selectCountList();
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.domain.exam.dto.ExamDTO;
import com.ruoyi.system.domain.userexam.ElUserExam;
import com.ruoyi.system.domain.userexam.dto.request.UserExamReqDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamCountDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamRespDTO;
import java.util.List;
@ -19,4 +20,7 @@ public interface ElUserExamService extends IService<ElUserExam> {
public List<UserExamRespDTO> selectExamList(UserExamReqDTO reqDTO);
public UserExamCountDTO selectCountList();
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.exam.dto.ExamDTO;
import com.ruoyi.system.domain.userexam.ElUserExam;
import com.ruoyi.system.domain.userexam.dto.request.UserExamReqDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamCountDTO;
import com.ruoyi.system.domain.userexam.dto.response.UserExamRespDTO;
import com.ruoyi.system.mapper.ElUserExamMapper;
import com.ruoyi.system.service.ElUserExamService;
@ -28,6 +29,11 @@ public class ElUserExamServiceImpl extends ServiceImpl<ElUserExamMapper, ElUserE
public List<UserExamRespDTO> selectExamList(UserExamReqDTO reqDTO) {
return userExamMapper.selectExamList(reqDTO);
}
@Override
public UserExamCountDTO selectCountList() {
return userExamMapper.selectCountList();
}
}

@ -39,4 +39,17 @@
AND uc.user_name LIKE CONCAT('%',#{userName},'%')
</if>
</select>
<select id="selectCountList" resultType="com.ruoyi.system.domain.userexam.dto.response.UserExamCountDTO">
SELECT
COUNT (1) AS total,
SUM (CASE WHEN passed = 1 THEN 1 ELSE 0 END) AS tg,
SUM (CASE WHEN passed = 0 THEN 1 ELSE 0 END) AS wtg
FROM
el_user_exam u
ORDER BY u.create_time
</select>
</mapper>

Loading…
Cancel
Save