diff --git a/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java b/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java index e079fe8..0413b24 100644 --- a/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java +++ b/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java @@ -26,8 +26,11 @@ public interface ProjectRcordControllerApi { @ApiOperation(value = "个人实验概览",notes = "个人实验概览") R getUserScore(Integer userid); - @ApiOperation(value = "个人实验记录导出",notes = "个人实验记录导出") + @ApiOperation(value = "个人虚拟仿真实验记录导出",notes = "个人虚拟仿真实验记录导出") void exportProjectRecord(HttpServletResponse response,Integer userId)throws Exception; + + @ApiOperation(value = "个人教学实验记录导出",notes = "个人教学实验记录导出") + void exportExperimentProjectRecord(HttpServletResponse response,Integer userId)throws Exception; // @ApiOperation(value = "个人实验记录导出",notes = "个人实验记录导出") // void exportProjectRecord(HttpServletResponse response,Integer userId)throws Exception; diff --git a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java index b8f208d..e8967c5 100644 --- a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java +++ b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java @@ -56,7 +56,7 @@ public class ProjectRecordController implements ProjectRcordControllerApi { * 用户端虚拟仿真实验记录 * @param page * @param size - * @param userid + * @param * @return */ @Override @@ -109,7 +109,7 @@ public class ProjectRecordController implements ProjectRcordControllerApi { /** - * 导出个人项目记录 + * 导出个人虚拟仿真实验记录 * @param response * @param userId * @throws Exception @@ -117,7 +117,20 @@ public class ProjectRecordController implements ProjectRcordControllerApi { @Override @GetMapping("/user/exportProjectRecord") public void exportProjectRecord(HttpServletResponse response,@RequestParam("userId") Integer userId)throws Exception{ - projectRecordService.exportProjectRecord(response,userId); + projectRecordService.exportProjectRecord(response,userId); + + } + + /** + * 导出个人教学实验记录 + * @param response + * @param userId + * @throws Exception + */ + @Override + @GetMapping("/user/exportExperimentProjectRecord") + public void exportExperimentProjectRecord(HttpServletResponse response,@RequestParam("userId") Integer userId)throws Exception{ + projectRecordService.exportExperimentProjectRecord(response,userId); } /** diff --git a/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java b/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java new file mode 100644 index 0000000..2dac435 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/request/ExperimentProjectRecordImportRequest.java @@ -0,0 +1,43 @@ +package com.msdw.tms.entity.request; + +import com.msdw.tms.common.utils.poi.ExcelAttribute; +import lombok.Data; + +/** + * 教学实验记录导出模板 + */ +@Data +public class ExperimentProjectRecordImportRequest { + /** + * 实验班级名称 + */ + @ExcelAttribute(sort = 0) + private String experimentalClassName; + + /** + * 实验项目名称 + */ + @ExcelAttribute(sort = 1) + private String projectName; + + /** + * 得分 + */ + @ExcelAttribute(sort = 2) + private Integer score; + /** + * 耗时 + */ + @ExcelAttribute(sort = 3) + private Integer timeSum; + /** + * 起始时间 + */ + @ExcelAttribute(sort = 4) + private String startTime; + /** + * 结束时间 + */ + @ExcelAttribute(sort = 5) + private String endTime; +} diff --git a/src/main/java/com/msdw/tms/entity/request/ProjectRecordImportRequest.java b/src/main/java/com/msdw/tms/entity/request/ProjectRecordImportRequest.java index eef5c6f..e54652d 100644 --- a/src/main/java/com/msdw/tms/entity/request/ProjectRecordImportRequest.java +++ b/src/main/java/com/msdw/tms/entity/request/ProjectRecordImportRequest.java @@ -3,6 +3,9 @@ package com.msdw.tms.entity.request; import com.msdw.tms.common.utils.poi.ExcelAttribute; import lombok.Data; +/** + * 虚拟仿真试验记录导出模板 + */ @Data public class ProjectRecordImportRequest { @@ -18,36 +21,45 @@ public class ProjectRecordImportRequest { // private String userRecordstate; // // private Integer recordstate; - /** - * 实验班级名称 - */ - @ExcelAttribute(sort = 1) - private String experimental_class_name; - +// /** +// * 得分 +// */ +// @ExcelAttribute(sort = 2) +// private Integer score; +// /** +// * 耗时 +// */ +// @ExcelAttribute(sort = 3) +// private Integer timeSum; +// /** +// * 起始时间 +// */ +// @ExcelAttribute(sort = 4) +// private String startTime; +// /** +// * 结束时间 +// */ +// @ExcelAttribute(sort = 5) +// private String endTime; /** * 得分 */ - @ExcelAttribute(sort = 2) + @ExcelAttribute(sort = 1) private Integer score; /** * 耗时 */ - @ExcelAttribute(sort = 3) + @ExcelAttribute(sort = 2) private Integer timeSum; /** * 起始时间 */ - @ExcelAttribute(sort = 4) + @ExcelAttribute(sort = 3) private String startTime; /** * 结束时间 */ - @ExcelAttribute(sort = 5) + @ExcelAttribute(sort = 4) private String endTime; - /** - * 结束时间 - */ - @ExcelAttribute(sort = 6) - private String abc; } diff --git a/src/main/java/com/msdw/tms/service/ProjectRecordService.java b/src/main/java/com/msdw/tms/service/ProjectRecordService.java index 410cf02..957200e 100644 --- a/src/main/java/com/msdw/tms/service/ProjectRecordService.java +++ b/src/main/java/com/msdw/tms/service/ProjectRecordService.java @@ -25,6 +25,8 @@ public interface ProjectRecordService extends IService { void exportProjectRecord(HttpServletResponse response, Integer userId)throws Exception; + void exportExperimentProjectRecord(HttpServletResponse response, Integer userId)throws Exception; + PageUtils querySchoolRecord(Integer page,Integer size,ProjectRecordVo projectRecord); boolean updateUserRecord(ProjectRecordEntity projectRecord); diff --git a/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java index ba01fa7..c480cef 100644 --- a/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java @@ -8,6 +8,7 @@ import com.msdw.tms.common.utils.PageUtils; import com.msdw.tms.common.utils.poi.ExcelExportUtil; import com.msdw.tms.dao.ProjectRecordDao; import com.msdw.tms.entity.ProjectRecordEntity; +import com.msdw.tms.entity.request.ExperimentProjectRecordImportRequest; import com.msdw.tms.entity.request.ProjectRecordImportRequest; import com.msdw.tms.entity.vo.ProjectRecordExportVo; import com.msdw.tms.entity.vo.ProjectRecordVo; @@ -19,9 +20,8 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletResponse; -import java.io.FileInputStream; +import java.io.InputStream; import java.util.List; -import java.util.function.Function; import java.util.stream.Collectors; @@ -86,12 +86,44 @@ public class ProjectRecordServiceImpl extends ServiceImpl projectRecordVos = this.baseMapper.getByUserRecordImport(projectRecord); + + List importRequests = projectRecordVos.stream().map(project -> { + ExperimentProjectRecordImportRequest request = new ExperimentProjectRecordImportRequest(); + BeanUtils.copyProperties(project, request); +// request.setUserRecordstate(project.getRecordstate().equals(1) ? "已完成":"待评分"); + return request; + }).collect(Collectors.toList()); + + //2.加载模板流数据 + ClassPathResource resource = new ClassPathResource("excel-template/教学实验报告导出模板.xlsx"); + InputStream inputStream = resource.getInputStream(); + + + //3、通过工具类下载文件 + new ExcelExportUtil(ExperimentProjectRecordImportRequest.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). + export(response, inputStream, importRequests, "教学实验报告.xlsx"); } @Override diff --git a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java index 025a648..9cbceff 100644 --- a/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java @@ -39,6 +39,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -623,10 +624,11 @@ public class QuestionsServiceImpl extends ServiceImpland `status` = #{cla.status} and ( project_name like concat('%',#{cla.condition},'%') or experimental_class_name like concat('%',#{cla.condition},'%') ) and stop_time between #{cla.endTime} and #{cla.startTime}