Browse Source

课程班级

大数据与最优化研究所 5 months ago
parent
commit
70c25c732b

+ 18 - 3
src/main/java/com/xjrsoft/module/base/controller/BaseClassCourseController.java

@@ -15,6 +15,7 @@ import com.xjrsoft.module.base.dto.*;
 import com.xjrsoft.module.base.entity.*;
 import com.xjrsoft.module.base.service.IBaseClassCourseService;
 import com.xjrsoft.module.base.service.impl.BaseCourseSubjectServiceImpl;
+import com.xjrsoft.module.base.vo.BaseClassCourseExportListVo;
 import com.xjrsoft.module.base.vo.BaseClassCourseListVo;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
 import com.xjrsoft.module.base.vo.BaseClassCourseVo;
@@ -231,10 +232,24 @@ public class BaseClassCourseController {
 
     @GetMapping("/export")
     @ApiOperation(value = "导出")
-    public ResponseEntity<byte[]> exportData(@Valid BaseClassCoursePageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
-        List<BaseClassCoursePageVo> customerList = isTemplate != null && isTemplate ? new ArrayList<>() : ((PageOutput<BaseClassCoursePageVo>) page(dto).getData()).getList();
+    public ResponseEntity<byte[]> exportData() {
+        MPJLambdaWrapper<BaseClassCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        baseClassCourseMPJLambdaWrapper
+                .select(BaseClassCourse::getCourseId)
+                .selectAs(BaseClass::getName, BaseClassCourseExportListVo::getClassIdCn)
+                .selectAs(BaseCourseSubject::getName, BaseClassCourseExportListVo::getCourseIdCn)
+                .selectAs(Textbook::getBookName, BaseClassCourseExportListVo::getTextbookIdCn)
+                .selectAs(BaseSemester::getName, BaseClassCourseExportListVo::getBaseSemesterIdCn)
+                .select(BaseClassCourse.class, x -> VoToColumnUtil.fieldsToColumns(BaseClassCourseExportListVo.class).contains(x.getProperty()))
+                .leftJoin(BaseClass.class, BaseClass::getId, BaseClassCourse::getClassId)
+                .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
+                .leftJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
+                .leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassCourse::getBaseSemesterId)
+        ;
+
+        List<BaseClassCourseExportListVo> customerList = baseClassCourseService.selectJoinList(BaseClassCourseExportListVo.class, baseClassCourseMPJLambdaWrapper);
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
-        EasyExcel.write(bot, BaseClassCoursePageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
+        EasyExcel.write(bot, BaseClassCourseExportListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
 
         return RT.fileStream(bot.toByteArray(), "BaseClassCourse" + ExcelTypeEnum.XLSX.getValue());
     }

+ 38 - 0
src/main/java/com/xjrsoft/module/base/vo/BaseClassCourseExportListVo.java

@@ -0,0 +1,38 @@
+package com.xjrsoft.module.base.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 班级课程分页列表出参
+* @Author brealinxx
+* @Date: 2024-06-04
+* @Version 1.0
+*/
+@Data
+public class BaseClassCourseExportListVo {
+
+    @ExcelProperty("学期")
+    private String baseSemesterIdCn;
+
+    /**
+     * 班级id(base_class)
+     */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("班级id(base_class)")
+    private String classIdCn;
+
+    @ApiModelProperty("课程id")
+    @ExcelProperty("课程id")
+    private String courseIdCn;
+
+    /**
+     * 教材id(textbook)
+     */
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("教材id(textbook)")
+    private String textbookIdCn;
+
+}