diff --git a/src/main/java/com/msdw/tms/api/AchievementManagementApi.java b/src/main/java/com/msdw/tms/api/AchievementManagementApi.java index 42ff62a..61eb7ed 100644 --- a/src/main/java/com/msdw/tms/api/AchievementManagementApi.java +++ b/src/main/java/com/msdw/tms/api/AchievementManagementApi.java @@ -64,7 +64,7 @@ public interface AchievementManagementApi { @ApiParam(value = "每页显示数据量", required = true) Integer size); @ApiOperation(value = "班级实验成绩导出", notes = "班级实验成绩导出") - void exportAchievement(HttpServletResponse response, @ApiParam(value = "实验记录集合recordId(此处为ids字符串(1,2,3))") String ids) throws Exception; + void exportAchievement(HttpServletResponse response, @ApiParam(value = "实验记录集合recordId(此处为ids字符串(1,2,3))") String ids, @ApiParam(value = "来源(1.练习2.考核)") Integer source) throws Exception; @ApiOperation(value = "成绩管理列表", notes = "成绩管理列表筛选查询") R queryAchievement(@ApiParam(value = "平台id", required = false) Integer systemId, @@ -82,8 +82,8 @@ public interface AchievementManagementApi { @ApiOperation(value = "成绩管理批量删除项目", notes = "将项目管理下的成绩管理批量删除") R deleteReportByIds(@ApiParam(value = "项目id", required = true) List projectIds, - @ApiParam(value = "项目类型(0练习,1考核)", required = true) Integer projectPermissions, - @ApiParam(value = "教学实验id",required = false) List ids); + @ApiParam(value = "项目类型(0练习,1考核)", required = true) Integer projectPermissions, + @ApiParam(value = "教学实验id", required = false) List ids); @ApiOperation(value = "成绩管理:虚拟仿真实验成绩管理", notes = "成绩管理:虚拟仿真实验成绩管理") diff --git a/src/main/java/com/msdw/tms/controller/AchievementManagementController.java b/src/main/java/com/msdw/tms/controller/AchievementManagementController.java index 3b2f903..37a20d5 100644 --- a/src/main/java/com/msdw/tms/controller/AchievementManagementController.java +++ b/src/main/java/com/msdw/tms/controller/AchievementManagementController.java @@ -229,8 +229,8 @@ public class AchievementManagementController implements AchievementManagementApi */ @Override @GetMapping("/exportAchievement") - public void exportAchievement(HttpServletResponse response, @RequestParam String ids) throws Exception { - service.exportAchievement(response, ids);//SearchAchievementVo vo + public void exportAchievement(HttpServletResponse response, @RequestParam String ids, @RequestParam Integer source) throws Exception { + service.exportAchievement(response, ids,source);//SearchAchievementVo vo } //成绩管理列表 @@ -281,9 +281,9 @@ public class AchievementManagementController implements AchievementManagementApi */ @Override @PostMapping("/deleteReportById") - public R deleteReportByIds(@RequestParam List projectIds,@RequestParam Integer projectPermissions, - @RequestParam(required = false) List ids) { - return service.deleteReportById(projectIds,projectPermissions,ids); + public R deleteReportByIds(@RequestParam List projectIds, @RequestParam Integer projectPermissions, + @RequestParam(required = false) List ids) { + return service.deleteReportById(projectIds, projectPermissions, ids); } /** diff --git a/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java b/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java index 799e79a..46004bd 100644 --- a/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java +++ b/src/main/java/com/msdw/tms/dao/AchievementManagementDao.java @@ -8,6 +8,7 @@ import com.msdw.tms.entity.ExperimentalTeachingEntity; import com.msdw.tms.entity.ReportEntity; import com.msdw.tms.entity.ResultsEntity; import com.msdw.tms.entity.request.AchievementImportRequest; +import com.msdw.tms.entity.request.ImportAssessmentRequest; import com.msdw.tms.entity.vo.AchievementManagementVO; import com.msdw.tms.entity.vo.JudgmentPointsRuleVO; import com.msdw.tms.entity.vo.ResultsVo; @@ -51,8 +52,12 @@ public interface AchievementManagementDao extends BaseMapper queryEvaluationReport(Page tPage, String searchContant, Integer projectId); + //导出练习 List queryAchievement(@Param("ids") List ids); + //导出考核 + List queryAchievementByAssessment(Integer id); + List queryFictitiousRecord(Integer systemId, String searchContant, String startingtime, String endtime, Integer month, List projectIds); List queryEducationRecord(Integer systemId, String searchContant, String startingtime, String endtime, Integer month, List projectIds); diff --git a/src/main/java/com/msdw/tms/entity/request/ImportAssessmentRequest.java b/src/main/java/com/msdw/tms/entity/request/ImportAssessmentRequest.java new file mode 100644 index 0000000..aca5e05 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/request/ImportAssessmentRequest.java @@ -0,0 +1,40 @@ +package com.msdw.tms.entity.request; + +import com.msdw.tms.common.utils.poi.ExcelAttribute; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 班级实验成绩导出模板数据 + */ +@Data +@Accessors(chain = true) +public class ImportAssessmentRequest { + + + //学校 + @ExcelAttribute(sort = 0) + private String schoolName; + + //考核名称 + @ExcelAttribute(sort = 1) + private String experimentalName; + + //学生姓名 + @ExcelAttribute(sort = 2) + private String userName; + + //学号 + @ExcelAttribute(sort = 3) + private String workNumber; + + //分数 + @ExcelAttribute(sort = 4) + private String score; + + //提交时间 + @ExcelAttribute(sort = 5) + private String submitTime; + + +} diff --git a/src/main/java/com/msdw/tms/service/AchievementManagementService.java b/src/main/java/com/msdw/tms/service/AchievementManagementService.java index b142c80..dfd3bc2 100644 --- a/src/main/java/com/msdw/tms/service/AchievementManagementService.java +++ b/src/main/java/com/msdw/tms/service/AchievementManagementService.java @@ -36,7 +36,7 @@ public interface AchievementManagementService extends IService projectId,Integer projectPermissions, List id); + R deleteReportById(List projectId, Integer projectPermissions, List id); List getImitationAchievement(Integer projectId); diff --git a/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java index 40089a4..69853a1 100644 --- a/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/AchievementManagementServiceImpl.java @@ -13,6 +13,7 @@ import com.msdw.tms.dao.ProjectRecordDao; import com.msdw.tms.dao.UserInfoDao; import com.msdw.tms.entity.*; import com.msdw.tms.entity.request.AchievementImportRequest; +import com.msdw.tms.entity.request.ImportAssessmentRequest; import com.msdw.tms.entity.vo.AchievementManagementVO; import com.msdw.tms.entity.vo.JudgmentPointsRuleVO; import com.msdw.tms.entity.vo.ResultsVo; @@ -121,47 +122,47 @@ public class AchievementManagementServiceImpl extends ServiceImpl studentName = userInfoDao.queryStudentName(userid); -// if (studentName.size()==0){ -// return R.error("不存在的学生姓名"); -// }else if (student==null){ -// log.info("学生姓名和用户id不匹配!!!"); -// return R.error("错误的个人信息!"); -// } + // RecordVo record = entity.getEntity(); + // //1.信息校验 + // String userName = entity.getUserName(); + // Integer userid = record.getUserid(); + // String teacherName = entity.getTeacherName(); + // //获取学生id和用户id + // StudentEntity student = userInfoDao.queryStudentId(userName,userid); + // //获取学生姓名 + // List studentName = userInfoDao.queryStudentName(userid); + // if (studentName.size()==0){ + // return R.error("不存在的学生姓名"); + // }else if (student==null){ + // log.info("学生姓名和用户id不匹配!!!"); + // return R.error("错误的个人信息!"); + // } //2.根据实验得分 自动获取评语信息 //3.将评语对应的commentId放入entity以便一齐存入实验报告表 //(无判分系统暂写score=100) -// record.setScore(100); -// //根据成绩取出对应的评语和评语id -// Integer score = record.getScore(); -// if (score!=null) { -// if (score<60){ -// entity.setCommentId(1);//成绩不合格 -// }else if (score>=60&&score<70){ -// entity.setCommentId(2);//合格 -// }else if (score>=70&&score<90){ -// entity.setCommentId(3);//良好 -// }else { -// entity.setCommentId(4);//优秀 -// } -// }else { -// return R.error("系统异常,成绩为空!"); -// } + // record.setScore(100); + // //根据成绩取出对应的评语和评语id + // Integer score = record.getScore(); + // if (score!=null) { + // if (score<60){ + // entity.setCommentId(1);//成绩不合格 + // }else if (score>=60&&score<70){ + // entity.setCommentId(2);//合格 + // }else if (score>=70&&score<90){ + // entity.setCommentId(3);//良好 + // }else { + // entity.setCommentId(4);//优秀 + // } + // }else { + // return R.error("系统异常,成绩为空!"); + // } //4.添加实验记录表信息 -// projectRecordDao.addReport(record);//保存至tms_project_record并返回主键 + // projectRecordDao.addReport(record);//保存至tms_project_record并返回主键 //5.添加实验报告表信息 -// entity.setStudentId(student.getStudentId()).setEventId(record.getEventId()); + // entity.setStudentId(student.getStudentId()).setEventId(record.getEventId()); achievementManagementDao.addReport(entity); return R.ok(); @@ -209,23 +210,43 @@ public class AchievementManagementServiceImpl extends ServiceImpl list = new ArrayList<>(); String[] split = ids.split(","); for (int i = 0; i < split.length; i++) { list.add(Integer.parseInt(split[i])); } - List achievement = achievementManagementDao.queryAchievement(list); - - //2.加载模板流数据 - ClassPathResource resource = new ClassPathResource("excel-template/川大成绩管理实验记录导出模板 (1).xlsx"); - InputStream inputStream = resource.getInputStream(); + switch (source) { + case 1: + //1.获取数据 + List achievement = achievementManagementDao.queryAchievement(list); + //2.加载模板流数据 + ClassPathResource resource = new ClassPathResource("excel-template/川大成绩管理实验记录导出模板 (1).xlsx"); + InputStream inputStream = resource.getInputStream(); + //3、通过工具类下载文件 + new ExcelExportUtil(AchievementImportRequest.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). + export(response, inputStream, achievement, "班级实验成绩.xlsx"); + break; + case 2: + //1.获取数据 + + Integer id = Integer.valueOf(list.get(0)); + List assessment = achievementManagementDao.queryAchievementByAssessment(id); + + //2.加载模板流数据 + ClassPathResource resource1 = new ClassPathResource("excel-template/川大成绩管理实验记录导出模板 (2).xlsx"); + InputStream inputStream1 = resource1.getInputStream(); + + //3、通过工具类下载文件 + new ExcelExportUtil(ImportAssessmentRequest.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). + export(response, inputStream1, assessment, "班级实验成绩.xlsx"); + break; + default: + return; + } - //3、通过工具类下载文件 - new ExcelExportUtil(AchievementImportRequest.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). - export(response, inputStream, achievement, "班级实验成绩.xlsx"); } @Override @@ -305,9 +326,9 @@ public class AchievementManagementServiceImpl extends ServiceImpl projectIds,Integer projectPermissions, List ids) { - if (projectPermissions == 1){//实验教学 - for (Integer id: ids) { + public R deleteReportById(List projectIds, Integer projectPermissions, List ids) { + if (projectPermissions == 1) {//实验教学 + for (Integer id : ids) { List teachAchievements = achievementManagementDao.getTeachAchievement(id); for (AchievementManagementVO teachAchievement : teachAchievements) { Integer reportId = teachAchievement.getReportId(); @@ -315,13 +336,13 @@ public class AchievementManagementServiceImpl extends ServiceImpl imitationAchievements = achievementManagementDao.getImitationAchievement(projectId); - for (AchievementManagementVO imitationAchievement: imitationAchievements) { + for (AchievementManagementVO imitationAchievement : imitationAchievements) { Integer reportId = imitationAchievement.getReportId(); Integer recordId = imitationAchievement.getRecordId(); - achievementManagementDao.deleteReport(reportId,recordId); + achievementManagementDao.deleteReport(reportId, recordId); } } } diff --git a/src/main/resources/excel-template/川大成绩管理实验记录导出模板 (2).xlsx b/src/main/resources/excel-template/川大成绩管理实验记录导出模板 (2).xlsx new file mode 100644 index 0000000..6744c8d Binary files /dev/null and b/src/main/resources/excel-template/川大成绩管理实验记录导出模板 (2).xlsx differ diff --git a/src/main/resources/mapper/tms/AchievementManagementDao.xml b/src/main/resources/mapper/tms/AchievementManagementDao.xml index 27a8558..c2a1330 100644 --- a/src/main/resources/mapper/tms/AchievementManagementDao.xml +++ b/src/main/resources/mapper/tms/AchievementManagementDao.xml @@ -236,6 +236,30 @@ tcr.reportId ORDER BY tpr.submitTime DESC + + +