提交
This commit is contained in:
1 parent
9e6cccf846
commit
7e5bd95470
6 files changed
+57
-24
No files matched your search
+20
-9
@@ -133,6 +133,18 @@ public class XgConductScoreController extends BaseController {
|
||||
@PostMapping("/listByDeptId")
|
||||
public TableDataInfo<XgConductScoreVo> listByDeptId(@RequestBody Map<String, Object> requestBody,
|
||||
PageQuery pageQuery) {
|
||||
// 从请求体中解析分页参数
|
||||
if (requestBody.containsKey("pageNum") && requestBody.get("pageNum") != null) {
|
||||
pageQuery.setPageNum(Integer.valueOf(requestBody.get("pageNum").toString()));
|
||||
} else {
|
||||
pageQuery.setPageNum(1);
|
||||
}
|
||||
if (requestBody.containsKey("pageSize") && requestBody.get("pageSize") != null) {
|
||||
pageQuery.setPageSize(Integer.valueOf(requestBody.get("pageSize").toString()));
|
||||
} else {
|
||||
pageQuery.setPageSize(10);
|
||||
}
|
||||
|
||||
// 从请求体中解析排序参数
|
||||
if (requestBody.containsKey("orderByColumn")) {
|
||||
pageQuery.setOrderByColumn((String) requestBody.get("orderByColumn"));
|
||||
@@ -747,6 +759,7 @@ public class XgConductScoreController extends BaseController {
|
||||
XgConductScoreImportVo example = new XgConductScoreImportVo();
|
||||
|
||||
// 设置示例数据
|
||||
example.setMonth(9);
|
||||
example.setStudentNo("2024001");
|
||||
example.setStudentName("张三");
|
||||
example.setScore(85);
|
||||
@@ -769,19 +782,17 @@ public class XgConductScoreController extends BaseController {
|
||||
@Log(title = "学生操行分", businessType = BusinessType.IMPORT)
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file,
|
||||
@NotNull(message = "学年不能为空") Integer academicYear,
|
||||
@NotNull(message = "学期不能为空") Integer semester,
|
||||
@NotNull(message = "月份不能为空") Integer month,
|
||||
String classId) throws Exception {
|
||||
log.info("导入操行分数据,学年: {}, 学期: {}, 月份: {}, 班级ID: {}", academicYear, semester, month, classId);
|
||||
@NotNull(message = "学年不能为空") Integer academicYear,
|
||||
@NotNull(message = "学期不能为空") Integer semester,
|
||||
String classId) throws Exception {
|
||||
log.info("导入操行分数据,学年: {}, 学期: {}, 班级ID: {}", academicYear, semester, classId);
|
||||
log.info("导入文件名: {}, 文件大小: {} bytes", file.getOriginalFilename(), file.getSize());
|
||||
|
||||
try {
|
||||
ExcelResult<XgConductScoreImportVo> result = ExcelUtil.importExcel(
|
||||
file.getInputStream(),
|
||||
XgConductScoreImportVo.class,
|
||||
new XgConductScoreImportListener(academicYear, semester, month, classId)
|
||||
);
|
||||
file.getInputStream(),
|
||||
XgConductScoreImportVo.class,
|
||||
new XgConductScoreImportListener(academicYear, semester, classId));
|
||||
|
||||
log.info("Excel导入完成,结果: {}", result.getAnalysis());
|
||||
return R.ok(result.getAnalysis());
|
||||
|
||||
+9
@@ -20,6 +20,15 @@ public class XgConductScoreImportVo implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 月份
|
||||
*/
|
||||
@ExcelProperty("月份")
|
||||
@NotNull(message = "月份不能为空")
|
||||
@Min(value = 1, message = "月份必须在1-12之间")
|
||||
@Max(value = 12, message = "月份必须在1-12之间")
|
||||
private Integer month;
|
||||
|
||||
/**
|
||||
* 学号
|
||||
*/
|
||||
|
||||
+10
-3
@@ -40,7 +40,6 @@ public class XgConductScoreImportListener extends AnalysisEventListener<XgConduc
|
||||
private final IXgStudentMsgService studentMsgService;
|
||||
private final Integer academicYear;
|
||||
private final Integer semester;
|
||||
private final Integer month;
|
||||
private final String classId; // 可选,指定班级ID
|
||||
private final Long operUserId;
|
||||
|
||||
@@ -49,12 +48,11 @@ public class XgConductScoreImportListener extends AnalysisEventListener<XgConduc
|
||||
private final StringBuilder successMsg = new StringBuilder();
|
||||
private final StringBuilder failureMsg = new StringBuilder();
|
||||
|
||||
public XgConductScoreImportListener(Integer academicYear, Integer semester, Integer month, String classId) {
|
||||
public XgConductScoreImportListener(Integer academicYear, Integer semester, String classId) {
|
||||
this.conductScoreService = SpringUtils.getBean(IXgConductScoreService.class);
|
||||
this.studentMsgService = SpringUtils.getBean(IXgStudentMsgService.class);
|
||||
this.academicYear = academicYear;
|
||||
this.semester = semester;
|
||||
this.month = month;
|
||||
this.classId = classId;
|
||||
this.operUserId = LoginHelper.getUserId();
|
||||
}
|
||||
@@ -65,6 +63,9 @@ public class XgConductScoreImportListener extends AnalysisEventListener<XgConduc
|
||||
// 1. 验证数据完整性
|
||||
validateImportData(importVo);
|
||||
|
||||
// 2. 获取月份参数(从Excel数据中读取)
|
||||
Integer month = importVo.getMonth();
|
||||
|
||||
// 2. 根据学号查找学生信息
|
||||
XgStudentMsgBo queryBo = new XgStudentMsgBo();
|
||||
queryBo.setStudentNo(importVo.getStudentNo());
|
||||
@@ -179,6 +180,12 @@ public class XgConductScoreImportListener extends AnalysisEventListener<XgConduc
|
||||
}
|
||||
|
||||
// 验证必填字段
|
||||
if (importVo.getMonth() == null) {
|
||||
throw new ServiceException("月份不能为空");
|
||||
}
|
||||
if (importVo.getMonth() < 1 || importVo.getMonth() > 12) {
|
||||
throw new ServiceException("月份必须在1-12之间");
|
||||
}
|
||||
if (StringUtils.isBlank(importVo.getStudentNo())) {
|
||||
throw new ServiceException("学号不能为空");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user