提交代码
This commit is contained in:
1 parent
5e0af12650
commit
7c78b3cf29
9 files changed
+791
-11
No files matched your search
+13
@@ -17,6 +17,7 @@ import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.xg.domain.vo.DormHygieneCheckExportVo;
|
||||
import org.dromara.xg.domain.vo.XgDormHygieneCheckVo;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckBo;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckCompleteBo;
|
||||
@@ -123,4 +124,16 @@ public class XgDormHygieneCheckController extends BaseController {
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
return toAjax(xgDormHygieneCheckService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出宿舍卫生检查列表(包含学生卫生情况)
|
||||
*/
|
||||
@SaCheckPermission("dormHygieneCheck:dormHygieneCheck:export")
|
||||
@Log(title = "宿舍卫生检查", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/advancedExport")
|
||||
public void advancedExport(XgDormHygieneCheckBo bo, HttpServletResponse response) {
|
||||
List<DormHygieneCheckExportVo> list = xgDormHygieneCheckService.queryExportList(bo);
|
||||
ExcelUtil.exportExcel(list, "宿舍卫生检查数据", DormHygieneCheckExportVo.class, response);
|
||||
}
|
||||
|
||||
}
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
package org.dromara.xg.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import org.dromara.xg.convert.StudentInfoExcelConvert;
|
||||
import org.dromara.xg.domain.XgDormHygieneCheck;
|
||||
import org.dromara.xg.domain.XgDormViolation;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 宿舍卫生检查导出 视图对象 dorm_hygiene_check_export
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-01-29
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = XgDormHygieneCheck.class)
|
||||
public class DormHygieneCheckExportVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 检查标题
|
||||
*/
|
||||
@ExcelProperty(value = "检查标题")
|
||||
private String checkTitle;
|
||||
|
||||
/**
|
||||
* 检查日期
|
||||
*/
|
||||
@ExcelProperty(value = "检查日期")
|
||||
private String checkDate;
|
||||
|
||||
/**
|
||||
* 检查员姓名
|
||||
*/
|
||||
@ExcelProperty(value = "检查员")
|
||||
private String checkerName;
|
||||
|
||||
/**
|
||||
* 检查类型
|
||||
*/
|
||||
@ExcelProperty(value = "检查类型")
|
||||
private String checkTypeText;
|
||||
|
||||
/**
|
||||
* 检查级别
|
||||
*/
|
||||
@ExcelProperty(value = "检查级别")
|
||||
private String checkLevelText;
|
||||
|
||||
/**
|
||||
* 校区名称
|
||||
*/
|
||||
@ExcelProperty(value = "校区")
|
||||
private String campusName;
|
||||
|
||||
/**
|
||||
* 宿舍区名称
|
||||
*/
|
||||
@ExcelProperty(value = "宿舍区")
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 宿舍楼名称
|
||||
*/
|
||||
@ExcelProperty(value = "宿舍楼")
|
||||
private String buildingName;
|
||||
|
||||
/**
|
||||
* 房间名称
|
||||
*/
|
||||
@ExcelProperty(value = "房间号")
|
||||
private String roomName;
|
||||
|
||||
/**
|
||||
* 宿舍总分
|
||||
*/
|
||||
@ExcelProperty(value = "宿舍总分")
|
||||
private Double totalScore;
|
||||
|
||||
/**
|
||||
* 卫生等级
|
||||
*/
|
||||
@ExcelProperty(value = "卫生等级")
|
||||
private String hygieneGradeText;
|
||||
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
@ExcelProperty(value = "学号")
|
||||
private String studentNo;
|
||||
|
||||
/**
|
||||
* 学生姓名
|
||||
*/
|
||||
@ExcelProperty(value = "学生姓名")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 班级名称
|
||||
*/
|
||||
@ExcelProperty(value = "班级")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 专业名称
|
||||
*/
|
||||
@ExcelProperty(value = "专业")
|
||||
private String majorName;
|
||||
|
||||
/**
|
||||
* 学院名称
|
||||
*/
|
||||
@ExcelProperty(value = "学院")
|
||||
private String collegeName;
|
||||
|
||||
/**
|
||||
* 床位编号
|
||||
*/
|
||||
@ExcelProperty(value = "床位号")
|
||||
private String bedCode;
|
||||
|
||||
/**
|
||||
* 学生个人得分
|
||||
*/
|
||||
@ExcelProperty(value = "个人得分")
|
||||
private Integer studentScore;
|
||||
|
||||
/**
|
||||
* 出勤状态
|
||||
*/
|
||||
@ExcelProperty(value = "出勤状态")
|
||||
private String attendanceStatusText;
|
||||
|
||||
/**
|
||||
* 学生评级
|
||||
*/
|
||||
@ExcelProperty(value = "个人评级")
|
||||
private String studentGradeText;
|
||||
|
||||
/**
|
||||
* 是否为寝室长
|
||||
*/
|
||||
// @ExcelProperty(value = "是否寝室长")
|
||||
// private String isResponsiblePersonText;
|
||||
|
||||
/**
|
||||
* 评分备注
|
||||
*/
|
||||
// @ExcelProperty(value = "评分备注")
|
||||
// private String scoreRemarks;
|
||||
|
||||
/**
|
||||
* 改进意见
|
||||
*/
|
||||
// @ExcelProperty(value = "改进意见")
|
||||
// private String improvementNotes;
|
||||
|
||||
/**
|
||||
* 检查总结
|
||||
*/
|
||||
@ExcelProperty(value = "检查总结")
|
||||
private String checkSummary;
|
||||
|
||||
/**
|
||||
* 整改建议
|
||||
*/
|
||||
@ExcelProperty(value = "整改建议")
|
||||
private String improvementSuggestions;
|
||||
|
||||
}
|
||||
+11
@@ -1,8 +1,11 @@
|
||||
package org.dromara.xg.mapper;
|
||||
|
||||
import org.dromara.xg.domain.XgDormHygieneCheck;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckBo;
|
||||
import org.dromara.xg.domain.vo.DormHygieneCheckExportVo;
|
||||
import org.dromara.xg.domain.vo.XgDormHygieneCheckVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 宿舍卫生检查Mapper接口
|
||||
@@ -12,4 +15,12 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface XgDormHygieneCheckMapper extends BaseMapperPlus<XgDormHygieneCheck, XgDormHygieneCheckVo> {
|
||||
|
||||
/**
|
||||
* 查询宿舍卫生检查导出列表(包含学生卫生情况)
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 导出数据列表
|
||||
*/
|
||||
List<DormHygieneCheckExportVo> selectExportList(XgDormHygieneCheckBo bo);
|
||||
|
||||
}
|
||||
+10
@@ -1,5 +1,6 @@
|
||||
package org.dromara.xg.service;
|
||||
|
||||
import org.dromara.xg.domain.vo.DormHygieneCheckExportVo;
|
||||
import org.dromara.xg.domain.vo.XgDormHygieneCheckVo;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckBo;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckCompleteBo;
|
||||
@@ -82,4 +83,13 @@ public interface IXgDormHygieneCheckService {
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateWithStudentScores(XgDormHygieneCheckCompleteBo bo);
|
||||
|
||||
/**
|
||||
* 查询宿舍卫生检查导出列表(包含学生卫生情况)
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 导出数据列表
|
||||
*/
|
||||
List<DormHygieneCheckExportVo> queryExportList(XgDormHygieneCheckBo bo);
|
||||
|
||||
}
|
||||
+121
@@ -14,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckBo;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneCheckCompleteBo;
|
||||
import org.dromara.xg.domain.bo.XgDormHygieneStudentScoreBo;
|
||||
import org.dromara.xg.domain.vo.DormHygieneCheckExportVo;
|
||||
import org.dromara.xg.domain.vo.XgDormHygieneCheckVo;
|
||||
import org.dromara.xg.domain.XgDormHygieneCheck;
|
||||
import org.dromara.xg.domain.XgDormHygieneStudentScore;
|
||||
@@ -341,4 +342,124 @@ public class XgDormHygieneCheckServiceImpl implements IXgDormHygieneCheckService
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询宿舍卫生检查导出列表(包含学生卫生情况)
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 导出数据列表
|
||||
*/
|
||||
@Override
|
||||
public List<DormHygieneCheckExportVo> queryExportList(XgDormHygieneCheckBo bo) {
|
||||
// 调用mapper查询导出数据
|
||||
List<DormHygieneCheckExportVo> exportList = baseMapper.selectExportList(bo);
|
||||
|
||||
// 转换字典值为文本
|
||||
for (DormHygieneCheckExportVo exportVo : exportList) {
|
||||
// 转换检查类型
|
||||
exportVo.setCheckTypeText(convertCheckTypeToText(exportVo.getCheckTypeText()));
|
||||
|
||||
// 转换检查级别
|
||||
exportVo.setCheckLevelText(convertCheckLevelToText(exportVo.getCheckLevelText()));
|
||||
|
||||
// 转换卫生等级
|
||||
exportVo.setHygieneGradeText(convertHygieneGradeToText(exportVo.getHygieneGradeText()));
|
||||
|
||||
// 转换出勤状态
|
||||
exportVo.setAttendanceStatusText(convertAttendanceStatusToText(exportVo.getAttendanceStatusText()));
|
||||
|
||||
// 转换学生评级
|
||||
exportVo.setStudentGradeText(convertStudentGradeToText(exportVo.getStudentGradeText()));
|
||||
|
||||
// 转换是否寝室长
|
||||
exportVo.setIsResponsiblePersonText(convertResponsiblePersonToText(exportVo.getIsResponsiblePersonText()));
|
||||
}
|
||||
|
||||
return exportList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换检查类型代码为文本
|
||||
*/
|
||||
private String convertCheckTypeToText(String checkType) {
|
||||
if (StringUtils.isEmpty(checkType)) {
|
||||
return "";
|
||||
}
|
||||
Map<String, String> typeMap = Map.of(
|
||||
"1", "日常检查",
|
||||
"2", "专项检查",
|
||||
"3", "突击检查",
|
||||
"4", "复查");
|
||||
return typeMap.getOrDefault(checkType, checkType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换检查级别代码为文本
|
||||
*/
|
||||
private String convertCheckLevelToText(String checkLevel) {
|
||||
if (StringUtils.isEmpty(checkLevel)) {
|
||||
return "";
|
||||
}
|
||||
Map<String, String> levelMap = Map.of(
|
||||
"1", "宿管员",
|
||||
"2", "学院",
|
||||
"3", "学校");
|
||||
return levelMap.getOrDefault(checkLevel, checkLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换卫生等级代码为文本
|
||||
*/
|
||||
private String convertHygieneGradeToText(String hygieneGrade) {
|
||||
if (StringUtils.isEmpty(hygieneGrade)) {
|
||||
return "";
|
||||
}
|
||||
Map<String, String> gradeMap = Map.of(
|
||||
"A", "优秀",
|
||||
"B", "良好",
|
||||
"C", "合格",
|
||||
"D", "不合格");
|
||||
return gradeMap.getOrDefault(hygieneGrade, hygieneGrade);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换出勤状态代码为文本
|
||||
*/
|
||||
private String convertAttendanceStatusToText(String attendanceStatus) {
|
||||
if (StringUtils.isEmpty(attendanceStatus)) {
|
||||
return "";
|
||||
}
|
||||
Map<String, String> statusMap = Map.of(
|
||||
"1", "在寝",
|
||||
"2", "外出",
|
||||
"3", "请假",
|
||||
"4", "其他");
|
||||
return statusMap.getOrDefault(attendanceStatus, attendanceStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换学生评级代码为文本
|
||||
*/
|
||||
private String convertStudentGradeToText(String studentGrade) {
|
||||
if (StringUtils.isEmpty(studentGrade)) {
|
||||
return "";
|
||||
}
|
||||
Map<String, String> gradeMap = Map.of(
|
||||
"A", "优秀",
|
||||
"B", "良好",
|
||||
"C", "合格",
|
||||
"D", "不合格");
|
||||
return gradeMap.getOrDefault(studentGrade, studentGrade);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换是否寝室长代码为文本
|
||||
*/
|
||||
private String convertResponsiblePersonToText(String isResponsiblePerson) {
|
||||
if (StringUtils.isEmpty(isResponsiblePerson)) {
|
||||
return "否";
|
||||
}
|
||||
return "1".equals(isResponsiblePerson) ? "是" : "否";
|
||||
}
|
||||
|
||||
}
|
||||
+114
@@ -4,4 +4,118 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.xg.mapper.XgDormHygieneCheckMapper">
|
||||
|
||||
<resultMap type="org.dromara.xg.domain.vo.DormHygieneCheckExportVo" id="DormHygieneCheckExportResult">
|
||||
<result property="checkTitle" column="check_title" />
|
||||
<result property="checkDate" column="check_date" />
|
||||
<result property="checkerName" column="checker_name" />
|
||||
<result property="checkTypeText" column="check_type" />
|
||||
<result property="checkLevelText" column="check_level" />
|
||||
<result property="campusName" column="campus_name" />
|
||||
<result property="areaName" column="area_name" />
|
||||
<result property="buildingName" column="building_name" />
|
||||
<result property="roomName" column="room_name" />
|
||||
<result property="totalScore" column="total_score" />
|
||||
<result property="hygieneGradeText" column="hygiene_grade" />
|
||||
<result property="studentNo" column="student_no" />
|
||||
<result property="studentName" column="student_name" />
|
||||
<result property="className" column="class_name" />
|
||||
<result property="majorName" column="major_name" />
|
||||
<result property="collegeName" column="college_name" />
|
||||
<result property="bedCode" column="bed_code" />
|
||||
<result property="studentScore" column="student_score" />
|
||||
<result property="attendanceStatusText" column="attendance_status" />
|
||||
<result property="studentGradeText" column="student_grade" />
|
||||
<result property="isResponsiblePersonText" column="is_responsible_person" />
|
||||
<result property="scoreRemarks" column="score_remarks" />
|
||||
<result property="improvementNotes" column="improvement_notes" />
|
||||
<result property="checkSummary" column="check_summary" />
|
||||
<result property="improvementSuggestions" column="improvement_suggestions" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectExportList" parameterType="org.dromara.xg.domain.bo.XgDormHygieneCheckBo" resultMap="DormHygieneCheckExportResult">
|
||||
SELECT
|
||||
dhc.check_title,
|
||||
DATE_FORMAT(dhc.check_date, '%Y-%m-%d') as check_date,
|
||||
dhc.checker_name,
|
||||
dhc.check_type,
|
||||
dhc.check_level,
|
||||
dhc.campus_name,
|
||||
dhc.area_name,
|
||||
dhc.building_name,
|
||||
dhc.room_name,
|
||||
dhc.total_score,
|
||||
dhc.hygiene_grade,
|
||||
dhc.check_summary,
|
||||
dhc.improvement_suggestions,
|
||||
COALESCE(dhss.student_no, '') as student_no,
|
||||
COALESCE(dhss.student_name, '') as student_name,
|
||||
COALESCE(dhss.class_name, '') as class_name,
|
||||
COALESCE(dhss.major_name, '') as major_name,
|
||||
COALESCE(dhss.college_name, '') as college_name,
|
||||
COALESCE(dhss.bed_code, '') as bed_code,
|
||||
COALESCE(dhss.student_score, 0) as student_score,
|
||||
COALESCE(dhss.attendance_status, '') as attendance_status,
|
||||
COALESCE(dhss.student_grade, '') as student_grade,
|
||||
COALESCE(dhss.is_responsible_person, 0) as is_responsible_person,
|
||||
COALESCE(dhss.score_remarks, '') as score_remarks,
|
||||
COALESCE(dhss.improvement_notes, '') as improvement_notes
|
||||
FROM xg_dorm_hygiene_check dhc
|
||||
LEFT JOIN xg_dorm_hygiene_student_score dhss ON dhc.id = dhss.hygiene_check_id AND dhss.deleted = 0
|
||||
<where>
|
||||
dhc.deleted = 0
|
||||
<if test="checkTitle != null and checkTitle != ''">
|
||||
AND dhc.check_title LIKE CONCAT('%', #{checkTitle}, '%')
|
||||
</if>
|
||||
<if test="checkDate != null and checkDate != ''">
|
||||
AND DATE_FORMAT(dhc.check_date, '%Y-%m-%d') = #{checkDate}
|
||||
</if>
|
||||
<if test="checkerId != null">
|
||||
AND dhc.checker_id = #{checkerId}
|
||||
</if>
|
||||
<if test="checkerName != null and checkerName != ''">
|
||||
AND dhc.checker_name LIKE CONCAT('%', #{checkerName}, '%')
|
||||
</if>
|
||||
<if test="checkType != null and checkType != ''">
|
||||
AND dhc.check_type = #{checkType}
|
||||
</if>
|
||||
<if test="checkLevel != null and checkLevel != ''">
|
||||
AND dhc.check_level = #{checkLevel}
|
||||
</if>
|
||||
<if test="roomId != null">
|
||||
AND dhc.room_id = #{roomId}
|
||||
</if>
|
||||
<if test="roomName != null and roomName != ''">
|
||||
AND dhc.room_name LIKE CONCAT('%', #{roomName}, '%')
|
||||
</if>
|
||||
<if test="buildingId != null">
|
||||
AND dhc.building_id = #{buildingId}
|
||||
</if>
|
||||
<if test="buildingName != null and buildingName != ''">
|
||||
AND dhc.building_name LIKE CONCAT('%', #{buildingName}, '%')
|
||||
</if>
|
||||
<if test="areaId != null">
|
||||
AND dhc.area_id = #{areaId}
|
||||
</if>
|
||||
<if test="areaName != null and areaName != ''">
|
||||
AND dhc.area_name LIKE CONCAT('%', #{areaName}, '%')
|
||||
</if>
|
||||
<if test="campusId != null">
|
||||
AND dhc.campus_id = #{campusId}
|
||||
</if>
|
||||
<if test="campusName != null and campusName != ''">
|
||||
AND dhc.campus_name LIKE CONCAT('%', #{campusName}, '%')
|
||||
</if>
|
||||
<if test="hygieneGrade != null and hygieneGrade != ''">
|
||||
AND dhc.hygiene_grade = #{hygieneGrade}
|
||||
</if>
|
||||
<if test="params != null and params.beginTime != null and params.beginTime != ''">
|
||||
AND dhc.check_date >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params != null and params.endTime != null and params.endTime != ''">
|
||||
AND dhc.check_date <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY dhc.check_date DESC, dhc.id ASC, dhss.student_no ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,289 @@
|
||||
# 宿舍卫生检查导出API文档
|
||||
|
||||
## 📋 概述
|
||||
|
||||
本文档描述宿舍卫生检查数据导出功能的API接口,支持导出宿舍卫生检查情况以及宿舍内学生的详细卫生情况信息。
|
||||
|
||||
**版本**: 1.0
|
||||
**创建时间**: 2025-01-29
|
||||
**最后更新**: 2025-01-29
|
||||
|
||||
---
|
||||
|
||||
## 🚀 导出功能特性
|
||||
|
||||
### 📊 导出数据内容
|
||||
- **宿舍卫生检查基本信息**:检查标题、检查日期、检查员、检查类型、检查级别
|
||||
- **宿舍地理位置信息**:校区、宿舍区、宿舍楼、房间号
|
||||
- **宿舍整体评价**:宿舍总分、卫生等级、检查总结、整改建议
|
||||
- **学生详细信息**:学号、姓名、班级、专业、学院、床位号
|
||||
- **学生个人评价**:个人得分、个人评级、出勤状态、是否寝室长
|
||||
- **改进建议**:评分备注、改进意见
|
||||
|
||||
### 📄 导出格式
|
||||
- **文件格式**: Excel (.xlsx)
|
||||
- **文件命名**: 宿舍卫生检查数据_YYYY-MM-DD.xlsx
|
||||
- **编码格式**: UTF-8
|
||||
|
||||
---
|
||||
|
||||
## 🔗 API接口详情
|
||||
|
||||
### 1. 导出宿舍卫生检查数据
|
||||
|
||||
#### 基本信息
|
||||
- **接口地址**: `POST /dormHygieneCheck/dormHygieneCheck/export`
|
||||
- **请求方式**: POST
|
||||
- **权限要求**: `dormHygieneCheck:dormHygieneCheck:export`
|
||||
- **返回类型**: 文件流 (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
|
||||
|
||||
#### 请求参数
|
||||
|
||||
| 参数名 | 类型 | 是否必填 | 说明 | 示例值 |
|
||||
|--------|------|----------|------|--------|
|
||||
| checkTitle | string | 否 | 检查标题 | "宿舍卫生大检查" |
|
||||
| checkDate | string | 否 | 检查日期 | "2025-01-29" |
|
||||
| checkerId | number | 否 | 检查员ID | 1001 |
|
||||
| checkerName | string | 否 | 检查员姓名 | "张老师" |
|
||||
| checkType | string | 否 | 检查类型 | "1"(日常检查) |
|
||||
| checkLevel | string | 否 | 检查级别 | "2"(学院) |
|
||||
| roomId | number | 否 | 房间ID | 2001 |
|
||||
| roomName | string | 否 | 房间名称 | "101" |
|
||||
| buildingId | number | 否 | 宿舍楼ID | 3001 |
|
||||
| buildingName | string | 否 | 宿舍楼名称 | "1号楼" |
|
||||
| areaId | number | 否 | 宿舍区ID | 4001 |
|
||||
| areaName | string | 否 | 宿舍区名称 | "北区" |
|
||||
| campusId | number | 否 | 校区ID | 5001 |
|
||||
| campusName | string | 否 | 校区名称 | "主校区" |
|
||||
| hygieneGrade | string | 否 | 卫生等级 | "A"(优秀) |
|
||||
| params.beginTime | string | 否 | 开始时间 | "2025-01-01" |
|
||||
| params.endTime | string | 否 | 结束时间 | "2025-01-31" |
|
||||
|
||||
#### 请求示例
|
||||
|
||||
```javascript
|
||||
// 前端调用示例
|
||||
const exportData = async () => {
|
||||
try {
|
||||
const queryParams = {
|
||||
checkTitle: "宿舍卫生大检查",
|
||||
checkDate: "2025-01-29",
|
||||
checkType: "1",
|
||||
checkLevel: "2",
|
||||
campusName: "主校区",
|
||||
hygieneGrade: "A",
|
||||
params: {
|
||||
beginTime: "2025-01-01",
|
||||
endTime: "2025-01-31"
|
||||
}
|
||||
};
|
||||
|
||||
const response = await exportDormHygieneCheck(queryParams);
|
||||
|
||||
// 创建下载链接
|
||||
const blob = new Blob([response.data], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
});
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `宿舍卫生检查数据_${new Date().toISOString().slice(0, 10)}.xlsx`;
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
|
||||
} catch (error) {
|
||||
console.error('导出失败:', error);
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
#### 响应说明
|
||||
|
||||
**成功响应**:
|
||||
- **Content-Type**: `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
|
||||
- **Content-Disposition**: `attachment; filename="宿舍卫生检查数据_2025-01-29.xlsx"`
|
||||
- **响应体**: Excel文件二进制数据流
|
||||
|
||||
**错误响应**:
|
||||
```json
|
||||
{
|
||||
"code": 500,
|
||||
"msg": "导出失败",
|
||||
"data": null
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Excel表格结构
|
||||
|
||||
### 表头字段说明
|
||||
|
||||
| 列序号 | 字段名 | 说明 | 示例值 |
|
||||
|--------|--------|------|--------|
|
||||
| 1 | 检查标题 | 本次检查的主题 | "宿舍卫生大检查" |
|
||||
| 2 | 检查日期 | 检查进行的日期 | "2025-01-29" |
|
||||
| 3 | 检查员 | 执行检查的人员 | "张老师" |
|
||||
| 4 | 检查类型 | 检查的类别 | "日常检查" |
|
||||
| 5 | 检查级别 | 检查的级别 | "学院" |
|
||||
| 6 | 校区 | 宿舍所在校区 | "主校区" |
|
||||
| 7 | 宿舍区 | 宿舍所在宿舍区 | "北区" |
|
||||
| 8 | 宿舍楼 | 宿舍所在楼栋 | "1号楼" |
|
||||
| 9 | 房间号 | 宿舍房间编号 | "101" |
|
||||
| 10 | 宿舍总分 | 宿舍整体得分 | 85 |
|
||||
| 11 | 卫生等级 | 宿舍卫生等级 | "优秀" |
|
||||
| 12 | 学号 | 学生学号 | "2023001001" |
|
||||
| 13 | 学生姓名 | 学生真实姓名 | "张三" |
|
||||
| 14 | 班级 | 学生所在班级 | "计算机科学与技术2023-1班" |
|
||||
| 15 | 专业 | 学生专业 | "计算机科学与技术" |
|
||||
| 16 | 学院 | 学生所属学院 | "计算机学院" |
|
||||
| 17 | 床位号 | 学生床位编号 | "A1" |
|
||||
| 18 | 个人得分 | 学生个人卫生得分 | 90 |
|
||||
| 19 | 出勤状态 | 检查时学生出勤情况 | "在寝" |
|
||||
| 20 | 个人评级 | 学生个人卫生等级 | "优秀" |
|
||||
| 21 | 是否寝室长 | 是否担任寝室长 | "是" |
|
||||
| 22 | 评分备注 | 评分相关说明 | "个人卫生良好" |
|
||||
| 23 | 改进意见 | 针对个人的改进建议 | "保持当前状态" |
|
||||
| 24 | 检查总结 | 宿舍整体检查总结 | "整体卫生状况良好" |
|
||||
| 25 | 整改建议 | 宿舍整体整改建议 | "继续保持" |
|
||||
|
||||
### 数据格式说明
|
||||
|
||||
#### 字典值转换
|
||||
- **检查类型**: 1-日常检查, 2-专项检查, 3-突击检查, 4-复查
|
||||
- **检查级别**: 1-宿管员, 2-学院, 3-学校
|
||||
- **卫生等级**: A-优秀, B-良好, C-合格, D-不合格
|
||||
- **出勤状态**: 1-在寝, 2-外出, 3-请假, 4-其他
|
||||
- **个人评级**: A-优秀, B-良好, C-合格, D-不合格
|
||||
- **是否寝室长**: 1-是, 0-否
|
||||
|
||||
#### 数据关联说明
|
||||
- 每条记录代表一个学生在特定宿舍卫生检查中的详细信息
|
||||
- 如果一个宿舍有多个学生,会产生多条记录,检查基本信息重复
|
||||
- 如果一个检查记录没有学生评分数据,学生相关字段显示为空
|
||||
|
||||
---
|
||||
|
||||
## 🔧 后端实现细节
|
||||
|
||||
### Controller层
|
||||
```java
|
||||
@SaCheckPermission("dormHygieneCheck:dormHygieneCheck:export")
|
||||
@Log(title = "宿舍卫生检查", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(DormHygieneCheckBo bo, HttpServletResponse response) {
|
||||
List<DormHygieneCheckExportVo> list = dormHygieneCheckService.queryExportList(bo);
|
||||
ExcelUtils.exportExcel(list, "宿舍卫生检查数据", DormHygieneCheckExportVo.class, response);
|
||||
}
|
||||
```
|
||||
|
||||
### Service层核心逻辑
|
||||
- 调用Mapper层查询导出数据
|
||||
- 进行字典值转换,将代码转换为可读文本
|
||||
- 返回格式化后的导出数据列表
|
||||
|
||||
### Mapper层SQL查询
|
||||
- 使用LEFT JOIN联合查询宿舍卫生检查表和学生评分表
|
||||
- 支持多种查询条件的灵活组合
|
||||
- 使用COALESCE函数处理空值
|
||||
- 按检查日期和学号排序
|
||||
|
||||
---
|
||||
|
||||
## 🛡️ 权限配置
|
||||
|
||||
### 权限标识
|
||||
```
|
||||
dormHygieneCheck:dormHygieneCheck:export
|
||||
```
|
||||
|
||||
### 权限配置SQL
|
||||
```sql
|
||||
-- 添加导出权限菜单
|
||||
INSERT INTO sys_menu (menu_name, parent_id, order_num, menu_type, visible, status, perms, remark)
|
||||
VALUES ('宿舍卫生检查导出', (父菜单ID), 5, 'F', '0', '0', 'dormHygieneCheck:dormHygieneCheck:export', '宿舍卫生检查导出权限');
|
||||
|
||||
-- 为相关角色分配权限
|
||||
INSERT INTO sys_role_menu (role_id, menu_id) VALUES (角色ID, 菜单ID);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧪 测试用例
|
||||
|
||||
### 测试场景1: 基础导出功能
|
||||
```javascript
|
||||
// 测试导出所有数据
|
||||
const testBasicExport = async () => {
|
||||
const response = await exportDormHygieneCheck({});
|
||||
// 验证返回的是Excel文件
|
||||
assert(response.headers['content-type'].includes('spreadsheetml.sheet'));
|
||||
};
|
||||
```
|
||||
|
||||
### 测试场景2: 条件筛选导出
|
||||
```javascript
|
||||
// 测试按条件筛选导出
|
||||
const testFilteredExport = async () => {
|
||||
const queryParams = {
|
||||
checkType: "1",
|
||||
hygieneGrade: "A",
|
||||
params: {
|
||||
beginTime: "2025-01-01",
|
||||
endTime: "2025-01-31"
|
||||
}
|
||||
};
|
||||
const response = await exportDormHygieneCheck(queryParams);
|
||||
// 验证数据筛选正确
|
||||
};
|
||||
```
|
||||
|
||||
### 测试场景3: 权限验证
|
||||
```javascript
|
||||
// 测试权限控制
|
||||
const testPermission = async () => {
|
||||
// 使用无权限用户访问
|
||||
try {
|
||||
await exportDormHygieneCheck({});
|
||||
assert(false, '应该抛出权限错误');
|
||||
} catch (error) {
|
||||
assert(error.response.status === 403);
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 使用说明
|
||||
|
||||
### 前端集成步骤
|
||||
1. 在API文件中导入`exportDormHygieneCheck`方法
|
||||
2. 在界面中添加导出按钮,绑定导出事件
|
||||
3. 调用导出API,处理文件下载
|
||||
4. 添加相应的错误处理和用户提示
|
||||
|
||||
### 注意事项
|
||||
- 导出功能需要相应的权限才能使用
|
||||
- 大量数据导出时建议添加加载提示
|
||||
- 建议在服务器端设置合理的数据量限制
|
||||
- 导出的Excel文件包含敏感学生信息,需要妥善保管
|
||||
|
||||
### 性能优化建议
|
||||
- 对于大量数据,考虑分页导出或异步导出
|
||||
- 在数据库层面优化联合查询性能
|
||||
- 考虑使用缓存机制减少重复查询
|
||||
|
||||
---
|
||||
|
||||
## 📞 联系信息
|
||||
|
||||
**开发团队**: 校园管理系统开发组
|
||||
**技术支持**: 系统管理员
|
||||
**文档维护**: 2025-01-29
|
||||
|
||||
---
|
||||
|
||||
*该文档将根据功能更新和用户反馈持续完善*
|
||||
@@ -1,8 +1,8 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import {
|
||||
DormHygieneCheckVO,
|
||||
DormHygieneCheckForm,
|
||||
import {
|
||||
DormHygieneCheckVO,
|
||||
DormHygieneCheckForm,
|
||||
DormHygieneCheckQuery,
|
||||
DormHygieneCheckCompleteForm,
|
||||
DormHygieneStudentScoreVO,
|
||||
@@ -201,3 +201,17 @@ export const getRoomOptions = (buildingId?: string | number): AxiosPromise<any[]
|
||||
params: buildingId ? { buildingId } : undefined
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出宿舍卫生检查数据(包含学生卫生情况)
|
||||
* @param query 查询条件
|
||||
* @returns Blob 导出文件数据
|
||||
*/
|
||||
export const exportDormHygieneCheck = (query?: DormHygieneCheckQuery) => {
|
||||
return request({
|
||||
url: '/dormHygieneCheck/dormHygieneCheck/advancedExport',
|
||||
method: 'post',
|
||||
data: query,
|
||||
responseType: 'blob'
|
||||
});
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="search-form-container">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
<el-form ref="queryFormRef" :model="queryParams">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="6">
|
||||
<el-form-item label="检查标题" prop="checkTitle">
|
||||
@@ -12,7 +12,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="检查日期" prop="checkDate">
|
||||
<el-form-item label="检查日期" prop="checkDate" style="width: 100%">
|
||||
<el-date-picker clearable v-model="queryParams.checkDate" type="date" value-format="YYYY-MM-DD" placeholder="请选择检查日期" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -74,7 +74,7 @@
|
||||
>导出</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar v-model="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
|
||||
<!-- 宿舍卫生检查弹窗组件 -->
|
||||
<DormHygieneCheckDialog
|
||||
v-model:visible="dialog.visible"
|
||||
v-model="dialog.visible"
|
||||
:title="dialog.title"
|
||||
:form-data="form"
|
||||
@submit="handleDialogSubmit"
|
||||
@@ -155,7 +155,8 @@ import {
|
||||
getDormHygieneCheck,
|
||||
delDormHygieneCheck,
|
||||
addDormHygieneCheck,
|
||||
updateDormHygieneCheck
|
||||
updateDormHygieneCheck,
|
||||
exportDormHygieneCheck
|
||||
} from '@/api/xg/xgss/dormHygieneCheck/dormHygieneCheck';
|
||||
import {
|
||||
DormHygieneCheckVO,
|
||||
@@ -383,13 +384,37 @@ const handleDelete = async (row?: DormHygieneCheckVO) => {
|
||||
};
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
const handleExport = async () => {
|
||||
// try {
|
||||
// ElMessage.info('正在导出数据,请稍候...');
|
||||
// const res = await exportDormHygieneCheck(queryParams.value);
|
||||
|
||||
// // 创建下载链接
|
||||
// const blob = new Blob([res.data], {
|
||||
// type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
// });
|
||||
// const url = window.URL.createObjectURL(blob);
|
||||
// const link = document.createElement('a');
|
||||
// link.href = url;
|
||||
// link.download = `宿舍卫生检查数据_${new Date().toISOString().slice(0, 10)}.xlsx`;
|
||||
|
||||
// // 触发下载
|
||||
// document.body.appendChild(link);
|
||||
// link.click();
|
||||
// document.body.removeChild(link);
|
||||
// window.URL.revokeObjectURL(url);
|
||||
|
||||
// ElMessage.success('导出成功');
|
||||
// } catch (error) {
|
||||
// console.error('导出失败:', error);
|
||||
// ElMessage.error('导出失败,请重试');
|
||||
// }
|
||||
proxy?.download(
|
||||
'dormHygieneCheck/dormHygieneCheck/export',
|
||||
'dormHygieneCheck/dormHygieneCheck/advancedExport',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`dormHygieneCheck_${new Date().getTime()}.xlsx`
|
||||
`宿舍卫生检查数据_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user