大数据与最优化研究所 пре 2 месеци
родитељ
комит
0b1362ec8d

+ 9 - 0
src/main/java/com/xjrsoft/common/enums/UseSemesterTypeEnum.java

@@ -51,4 +51,13 @@ public enum UseSemesterTypeEnum {
         }
         return 0;
     }
+
+    public static String getValue(int code) {
+        for (UseSemesterTypeEnum c : UseSemesterTypeEnum.values()) {
+            if (c.getCode() == code) {
+                return c.getValue();
+            }
+        }
+        return "未知";
+    }
 }

+ 8 - 24
src/main/java/com/xjrsoft/module/base/controller/BaseClassCourseController.java

@@ -28,14 +28,12 @@ import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.base.service.IBaseCourseSubjectService;
 import com.xjrsoft.module.base.service.IBaseSemesterService;
 import com.xjrsoft.module.base.vo.BaseClassCourseExcelVo;
-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;
-import com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryListDto;
+import com.xjrsoft.module.base.dto.ClassCourseTextbookExportQueryDto;
 import com.xjrsoft.module.textbook.entity.Textbook;
 import com.xjrsoft.module.textbook.service.ITextbookService;
-import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -304,27 +302,13 @@ public class BaseClassCourseController {
         return RT.ok(result);
     }
 
-    @GetMapping("/export")
-    @ApiOperation(value = "导出")
-    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, BaseClassCourseExportListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
-
+//    @PostMapping("/class-course-textbook-export-query")
+//    @ApiOperation(value = "班级课程教材详情条件导出")
+//    public ResponseEntity<byte[]> classCourseTextbookExportQuery(@Valid @RequestBody ClassCourseTextbookExportQueryDto dto) throws IOException {
+    @GetMapping("/class-course-textbook-export-query")
+    @ApiOperation(value = "班级课程教材详情条件导出")
+    public ResponseEntity<byte[]> classCourseTextbookExportQuery(@Valid ClassCourseTextbookExportQueryDto dto) throws IOException {
+        ByteArrayOutputStream bot = baseClassCourseService.classCourseTextbookExportQuery(dto);
         return RT.fileStream(bot.toByteArray(), "BaseClassCourse" + ExcelTypeEnum.XLSX.getValue());
     }
 }

+ 31 - 0
src/main/java/com/xjrsoft/module/base/dto/ClassCourseTextbookExportQueryDto.java

@@ -0,0 +1,31 @@
+package com.xjrsoft.module.base.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+* @title: 班级课程教材导出入参
+* @Author szs
+* @Date: 2024-02-19
+* @Version 1.0
+*/
+@Data
+public class ClassCourseTextbookExportQueryDto {
+    @ApiModelProperty("班级id集合")
+    private List<String> classIds;
+
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ApiModelProperty("所属机构")
+    private Long deptId;
+
+    @ApiModelProperty("教学课程设置(0:全部 1:已设置 2:未设置)")
+    private Integer courseSet;
+
+    @ApiModelProperty("学期id")
+    private Long semester;
+}

+ 5 - 2
src/main/java/com/xjrsoft/module/base/service/IBaseClassCourseService.java

@@ -8,9 +8,10 @@ import com.xjrsoft.module.base.entity.BaseClassCourse;
 import com.xjrsoft.module.base.entity.ClassCourseTextbook;
 import com.xjrsoft.module.base.entity.CourseBookInfo;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
-import com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryListDto;
-import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
+import com.xjrsoft.module.base.dto.ClassCourseTextbookExportQueryDto;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
@@ -52,4 +53,6 @@ public interface IBaseClassCourseService extends MPJBaseService<BaseClassCourse>
     boolean checkExits(Long classId, Long courseId, Long textbookId);
 
     boolean checkExitsWithoutTextbook(Long classId, Long courseId);
+
+    ByteArrayOutputStream classCourseTextbookExportQuery(ClassCourseTextbookExportQueryDto dto) throws IOException;
 }

+ 218 - 14
src/main/java/com/xjrsoft/module/base/service/impl/BaseClassCourseServiceImpl.java

@@ -1,43 +1,52 @@
 package com.xjrsoft.module.base.service.impl;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.UseSemesterTypeEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.base.dto.BaseClassCoursePageDto;
 import com.xjrsoft.module.base.dto.ClassCourseReuseDto;
-import com.xjrsoft.module.base.entity.BaseClassCourse;
-import com.xjrsoft.module.base.entity.BaseCourseSubject;
-import com.xjrsoft.module.base.entity.ClassCourseTextbook;
-import com.xjrsoft.module.base.entity.CourseBookInfo;
+import com.xjrsoft.module.base.entity.*;
 import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
+import com.xjrsoft.module.base.mapper.BaseClassMapper;
 import com.xjrsoft.module.base.service.IBaseClassCourseService;
+import com.xjrsoft.module.base.vo.BaseClassCourseExportListVo;
 import com.xjrsoft.module.base.vo.BaseClassCoursePageVo;
+import com.xjrsoft.module.generator.entity.ImportConfig;
+import com.xjrsoft.module.organization.entity.Department;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
+import com.xjrsoft.module.base.dto.ClassCourseTextbookExportQueryDto;
+import com.xjrsoft.module.base.vo.ClassCourseTextbookExportQueryVo;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
-import com.xjrsoft.module.textbook.dto.TextbookSubscriptionExportQueryListDto;
 import com.xjrsoft.module.textbook.entity.Textbook;
 import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
-import com.xjrsoft.module.textbook.entity.TextbookSubscription;
-import com.xjrsoft.module.textbook.entity.WfTextbookSubscriptionItem;
 import com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper;
-import com.xjrsoft.module.textbook.vo.TextbookSubscriptionExportQueryListVo;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.xjrsoft.module.veb.util.ImportExcelUtil.allFields;
+import static com.xjrsoft.module.veb.util.ImportExcelUtil.createHead;
+
 /**
 * @title: 班级课程
 * @Author brealinxx
@@ -54,6 +63,8 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
 
     private final TextbookStudentClaimMapper textbookStudentClaimMapper;
 
+    private final BaseClassMapper baseClassMapper;
+
     @Override
     public Page<BaseClassCoursePageVo> getPage(Page<BaseClassCoursePageVo> page, BaseClassCoursePageDto dto) {
         return baseClassCourseMapper.getPage(page, dto);
@@ -254,4 +265,197 @@ public class BaseClassCourseServiceImpl extends MPJBaseServiceImpl<BaseClassCour
     public boolean checkExitsWithoutTextbook(Long classId, Long courseId) {
         return this.baseMapper.checkExitsWithoutTextbook(classId, courseId);
     }
+
+    @Override
+    public ByteArrayOutputStream classCourseTextbookExportQuery(ClassCourseTextbookExportQueryDto dto) throws IOException {
+        MPJLambdaWrapper<BaseClass> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        baseClassCourseMPJLambdaWrapper
+                .disableSubLogicDel()
+                .selectAs(BaseSemester::getName, ClassCourseTextbookExportQueryVo::getSemester)
+                .selectAs(Department::getName, ClassCourseTextbookExportQueryVo::getDeptName)
+                .selectAs(BaseClass::getId, ClassCourseTextbookExportQueryVo::getClassId)
+                .selectAs(BaseClass::getName, ClassCourseTextbookExportQueryVo::getClassName)
+                .selectAs(BaseCourseSubject::getName, ClassCourseTextbookExportQueryVo::getCourseName)
+                .selectAs(Textbook::getBookName, ClassCourseTextbookExportQueryVo::getTextbookName)
+                .selectAs(Textbook::getUseType, ClassCourseTextbookExportQueryVo::getUseType)
+                .selectAs(Textbook::getPrice, ClassCourseTextbookExportQueryVo::getPrice)
+                .selectAs(Textbook::getDiscountPrice, ClassCourseTextbookExportQueryVo::getDiscountPrice)
+
+                .leftJoin(BaseClassCourse.class, BaseClassCourse::getClassId, BaseClass::getId)
+                .leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassCourse::getBaseSemesterId)
+                .leftJoin(BaseClass.class, BaseClass::getId, BaseClassCourse::getClassId)
+                .leftJoin(Department.class, Department::getId, BaseClass::getOrgId)
+                .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
+                .leftJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
+                .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
+                        wrapper -> wrapper
+                                .selectAs(DictionaryDetail::getName, ClassCourseTextbookExportQueryVo::getTextbookType)
+                        )
+                .in(ObjectUtils.isNotEmpty(dto.getClassIds()) && !dto.getClassIds().isEmpty(), BaseClassCourse::getClassId, dto.getClassIds())
+                .like(StringUtils.isNotBlank(dto.getClassName()), BaseClass::getName, dto.getClassName())
+                .eq(ObjectUtils.isNotEmpty(dto.getDeptId()), Department::getId, dto.getDeptId())
+                .having(ObjectUtils.isNotEmpty(dto.getCourseSet()) && dto.getCourseSet() == 1, "HAVING LENGTH(course_name) > 0")
+                .having(ObjectUtils.isNotEmpty(dto.getCourseSet()) && dto.getCourseSet() == 2, "HAVING COALESCE(LENGTH(course_name), 0) = 0")
+                .and(ObjectUtils.isNotEmpty(dto.getSemester()),
+                        wrapper -> wrapper
+                                .eq(BaseClassCourse::getBaseSemesterId, dto.getSemester())
+                                .or()
+                                .isNull(BaseClassCourse::getBaseSemesterId)
+                )
+                .and(wrapper -> wrapper
+                                .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
+                                .or()
+                                .isNull(BaseClassCourse::getDeleteMark)
+                )
+                .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+                .orderByDesc(BaseCourseSubject::getName)
+                .orderByDesc(Textbook::getBookName)
+        ;
+
+        List<ClassCourseTextbookExportQueryVo> dataList = baseClassMapper.selectJoinList(ClassCourseTextbookExportQueryVo.class, baseClassCourseMPJLambdaWrapper);
+
+        // 根据班级分组
+        Map<Long, List<ClassCourseTextbookExportQueryVo>> dataMapByClassId = dataList.stream()
+                .collect(Collectors.groupingBy(
+                        ClassCourseTextbookExportQueryVo::getClassId,
+                        LinkedHashMap::new, // 指定使用LinkedHashMap来保持顺序
+                        Collectors.toList()
+                ));
+
+        List<Long> classIds = dataList.stream()
+                .filter(c -> ObjectUtils.isNotEmpty(c.getClassId()))
+                .map(ClassCourseTextbookExportQueryVo::getClassId)
+                .collect(Collectors.toList());
+        if(classIds.isEmpty()){
+            throw new MyException("导出数据中班级有误,请刷新重试");
+        }
+
+        // 获取班级人数
+        MPJLambdaWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        baseStudentSchoolRollMPJLambdaWrapper
+                .selectAs(BaseStudentSchoolRoll::getClassId, BaseStudentSchoolRoll::getClassId)
+                .selectCount(BaseStudentSchoolRoll::getId, BaseStudentSchoolRoll::getDeleteMark)
+                .in(BaseStudentSchoolRoll::getClassId, classIds)
+                .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
+                .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
+                .groupBy(BaseStudentSchoolRoll::getClassId)
+                ;
+        List<BaseStudentSchoolRoll> baseStudentSchoolRolls = baseStudentSchoolRollMapper.selectJoinList(BaseStudentSchoolRoll.class, baseStudentSchoolRollMPJLambdaWrapper);
+
+        Map<Long, Integer> stuNumMap = baseStudentSchoolRolls.stream()
+                .collect(Collectors.toMap(BaseStudentSchoolRoll::getClassId, BaseStudentSchoolRoll::getDeleteMark, (k1,k2) -> k1));
+
+        // 处理数据
+        for (ClassCourseTextbookExportQueryVo c : dataList){
+            // 处理使用学期
+            if(ObjectUtils.isNotEmpty(c.getUseType())){
+                String useType = UseSemesterTypeEnum.getValue(c.getUseType());
+                c.setUseTypeCn(useType);
+            }else {
+                c.setUseTypeCn("未知");
+            }
+
+            // 处理班级人数
+            Integer stuNum = stuNumMap.get(c.getClassId());
+            if(ObjectUtils.isNotEmpty(stuNum)){
+                c.setStudentNum(stuNum);
+
+                // 处理总价
+                if(ObjectUtils.isNotEmpty(c.getDiscountPrice())){
+                    BigDecimal totalPrices = c.getDiscountPrice().multiply(BigDecimal.valueOf(stuNum));
+                    c.setTotalPrices(totalPrices);
+                }else {
+                    c.setTotalPrices(BigDecimal.ZERO);
+                }
+            }else {
+                c.setStudentNum(0);
+            }
+        }
+
+        // 开始写入
+        Workbook workbook = new XSSFWorkbook();
+        // 创建一个工作表(sheet)
+        String sheetName = "sheet1";
+        Sheet sheet = workbook.createSheet(sheetName);
+
+        List<ImportConfig> importConfigs = allFields(new ClassCourseTextbookExportQueryVo());
+
+        // 表头
+        createHead(workbook, sheet, importConfigs, 0);
+
+        // 内容
+        int dataRowNumber = 1;
+        Font font = workbook.createFont();
+        font.setFontName("宋体");
+        font.setFontHeightInPoints((short)12);
+
+        CellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font); // 将字体应用到样式
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+
+        for (Map.Entry<Long, List<ClassCourseTextbookExportQueryVo>> entry : dataMapByClassId.entrySet()){
+            Long key = entry.getKey();
+            List<ClassCourseTextbookExportQueryVo> value = entry.getValue();
+            List<List<String>> inList = new ArrayList<>();
+
+            // 小计合计
+            BigDecimal totalDiscountPrice = BigDecimal.ZERO;
+            for (ClassCourseTextbookExportQueryVo c : value){
+                totalDiscountPrice = totalDiscountPrice.add(ObjectUtils.isNotEmpty(c.getDiscountPrice()) ? c.getDiscountPrice() : BigDecimal.ZERO);
+            }
+            for (ClassCourseTextbookExportQueryVo c : value){
+                c.setTotalDiscountPrice(totalDiscountPrice);
+            }
+
+            // 总价合计
+            BigDecimal totalPriceTotal = BigDecimal.ZERO;
+            for (ClassCourseTextbookExportQueryVo c : value){
+                totalPriceTotal = totalPriceTotal.add(ObjectUtils.isNotEmpty(c.getTotalPrices()) ? c.getTotalPrices() : BigDecimal.ZERO);
+            }
+            for (ClassCourseTextbookExportQueryVo c : value){
+                c.setTotalPriceTotal(totalPriceTotal);
+            }
+
+            // 开始写入
+            for (ClassCourseTextbookExportQueryVo c : value){
+                List<String> date = new ArrayList<>();
+                date.add(c.getSemester());
+                date.add(c.getDeptName());
+                date.add(c.getClassName());
+                date.add(c.getCourseName());
+                date.add(c.getTextbookName());
+                date.add(c.getUseTypeCn());
+                date.add(c.getTextbookType());
+                date.add(ObjectUtils.isNotEmpty(c.getPrice()) ? c.getPrice().toString() : "0");
+                date.add(ObjectUtils.isNotEmpty(c.getDiscountPrice()) ? c.getDiscountPrice().toString() : "0");
+                date.add(ObjectUtils.isNotEmpty(c.getTotalDiscountPrice()) ? c.getTotalDiscountPrice().toString() : "0");
+                date.add(c.getStudentNum() + "");
+                date.add(ObjectUtils.isNotEmpty(c.getTotalPrices()) ? c.getTotalPrices().toString() : "0");
+                date.add(ObjectUtils.isNotEmpty(c.getTotalPriceTotal()) ? c.getTotalPriceTotal().toString() : "0");
+                inList.add(date);
+            }
+
+            for (List<String> rowData : inList) {
+                Row dataRow = sheet.createRow(dataRowNumber);
+                for (int i = 0; i < rowData.size(); i++) {
+                    sheet.autoSizeColumn(i);
+                    Cell cell = dataRow.createCell(i);
+                    cell.setCellValue(rowData.get(i));
+                    cell.setCellStyle(cellStyle);
+                }
+                dataRowNumber++;
+            }
+            if(inList.size() > 1){
+                sheet.addMergedRegion(new CellRangeAddress(dataRowNumber - inList.size(), dataRowNumber - 1, 9, 9));
+                sheet.addMergedRegion(new CellRangeAddress(dataRowNumber - inList.size(), dataRowNumber - 1, 10, 10));
+                sheet.addMergedRegion(new CellRangeAddress(dataRowNumber - inList.size(), dataRowNumber - 1, 12, 12));
+            }
+        }
+
+        //写入文件
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        workbook.write(bot);
+        return bot;
+    }
 }

+ 4 - 4
src/main/java/com/xjrsoft/module/base/vo/BaseClassCoursePageVo.java

@@ -65,9 +65,9 @@ public class BaseClassCoursePageVo {
 
     @ApiModelProperty("总定价")
     @ExcelProperty("总定价")
-    private BigDecimal totalPrice;
+    private BigDecimal amount;
 
-    @ApiModelProperty("学期")
-    @ExcelProperty("学期")
-    private String semester;
+    @ApiModelProperty("总小计")
+    @ExcelProperty("总小计")
+    private BigDecimal count;
 }

+ 90 - 0
src/main/java/com/xjrsoft/module/base/vo/ClassCourseTextbookExportQueryVo.java

@@ -0,0 +1,90 @@
+package com.xjrsoft.module.base.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+* @title: 班级课程教材导出出参
+* @Author phoenix
+* @Date: 2024-12-23
+* @Version 1.0
+*/
+@Data
+public class ClassCourseTextbookExportQueryVo {
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("学期")
+    @ApiModelProperty("学期")
+    private String semester;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("所属机构")
+    @ApiModelProperty("所属机构")
+    private String deptName;
+
+    @ExcelIgnore
+    @ApiModelProperty("班级主键id")
+    private Long classId;
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("班级")
+    @ApiModelProperty("班级名称")
+    private String className;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("课程")
+    @ExcelProperty("教学课程")
+    private String courseName;
+
+    @ContentStyle(dataFormat = 49)
+    @ApiModelProperty("教材")
+    @ExcelProperty("对应教材")
+    private String textbookName;
+
+    @ExcelIgnore
+    @ApiModelProperty("使用类型(单位:学期)")
+    private Integer useType;
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("使用类型")
+    @ApiModelProperty("使用类型(单位:学期)")
+    private String useTypeCn;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("教材分类")
+    @ApiModelProperty("教材分类(xjr_dictionary_item[textbook_type])")
+    private String textbookType;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("定价")
+    @ApiModelProperty("定价(元)")
+    private BigDecimal price;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("小计")
+    @ApiModelProperty("预估折扣后的价格")
+    private BigDecimal discountPrice;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("小计合计")
+    @ApiModelProperty("小计合计")
+    private BigDecimal totalDiscountPrice;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("班级人数")
+    @ApiModelProperty("班级人数")
+    private Integer studentNum;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("总价")
+    @ApiModelProperty("总价")
+    private BigDecimal totalPrices;
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("总价合计")
+    @ApiModelProperty("总价合计")
+    private BigDecimal totalPriceTotal;
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/textbook/controller/TextbookWarehouseRecordController.java

@@ -53,7 +53,7 @@ public class TextbookWarehouseRecordController {
     @ApiOperation(value="教材入库列表(分页)")
     @SaCheckPermission("textbookclasswarehouse:detail")
     public RT<PageOutput<TextbookWarehouseRecordPageVo>> page(@Valid TextbookWarehouseRecordPageDto dto){
-        Page<TextbookWarehouseRecordPageVo> page = textbookClassWarehouseService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
+        Page<TextbookWarehouseRecordPageVo> page = textbookClassWarehouseService.getPage(dto);
         PageOutput<TextbookWarehouseRecordPageVo> pageOutput = ConventPage.getPageOutput(page, TextbookWarehouseRecordPageVo.class);
         return RT.ok(pageOutput);
     }

+ 5 - 2
src/main/java/com/xjrsoft/module/textbook/entity/Textbook.java

@@ -179,6 +179,9 @@ public class Textbook implements Serializable {
     */
     @ApiModelProperty("预估折扣")
     private Double discount;
-
-
+    /**
+     * 预估折扣
+     */
+    @ApiModelProperty("预估折扣后的价格")
+    private BigDecimal discountPrice;
 }

+ 1 - 1
src/main/java/com/xjrsoft/module/textbook/service/ITextbookWarehouseRecordService.java

@@ -19,7 +19,7 @@ import java.util.List;
 
 public interface ITextbookWarehouseRecordService extends MPJBaseService<TextbookWarehouseRecord> {
 
-    Page<TextbookWarehouseRecordPageVo> getPage(Page<TextbookWarehouseRecordPageDto> page, TextbookWarehouseRecordPageDto dto);
+    Page<TextbookWarehouseRecordPageVo> getPage(TextbookWarehouseRecordPageDto dto);
 
     List<TextbookWarehouseRecordPageVo> getList(TextbookWarehouseRecordExportDto dto);
 

+ 44 - 21
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookServiceImpl.java

@@ -114,6 +114,10 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
         }
 
         textbook.setIsbn(textbook.getIssn());
+        if(ObjectUtils.isNotEmpty(textbook.getDiscount()) && ObjectUtils.isNotEmpty(textbook.getPrice())){
+            BigDecimal discount =  BigDecimal.valueOf(textbook.getDiscount()).divide( BigDecimal.valueOf(10));
+            textbook.setDiscountPrice(textbook.getPrice().multiply(discount));
+        }
 
         // 判断导入的教材是否已经存在,根据教材的 ISSN 码和使用的学科组和课程判断
         LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -125,6 +129,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
         ;
 
         Textbook verifyTextbook = textbookTextbookMapper.selectOne(textbookLambdaQueryWrapper);
+
         int num;
         if(ObjectUtils.isNotEmpty(verifyTextbook)){
             textbook.setId(verifyTextbook.getId());
@@ -1222,7 +1227,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
             TextbookImportDto dto = excelDataList.get(i);
             if (isRequiredFieldsFilled(dto,
                     sb,
-                    i+2)) {
+                    i+3)) {
                 return sb.toString();
             }
 
@@ -1237,7 +1242,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     dictionary,
                     textbook::setTextbookType,
                     sb,
-                    i+2)) {
+                    i+3)) {
                 return sb.toString();
             }
             if (validateAndSetDictionaryField(dto::getTextbookCategory,
@@ -1246,7 +1251,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     dictionary,
                     textbook::setTextbookCategory,
                     sb,
-                    i+2)) {
+                    i+3)) {
                 return sb.toString();
             }
 
@@ -1256,7 +1261,7 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     subjectGroupNameAndIdMap,
                     textbook::setSubjectGroupId,
                     sb,
-                    i+2
+                    i+3
             )) {
                 return sb.toString();
             }
@@ -1265,38 +1270,56 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
                     baseCourseSubjectNameAndIdMap,
                     textbook::setCourseSubjectId,
                     sb,
-                    i+2
+                    i+3
             )) {
                 return sb.toString();
             }
 
-            // 处理是否教材计划字段
-            String isTextbookPlanCn = dto.getIsTextbookPlanCn();
-            Integer isTextbookPlan = Optional.ofNullable(isTextbookPlanCn)
-                    .filter("是"::equals)
-                    .map(s -> 1)
-                    .orElse(0);
-            textbook.setIsTextbookPlan(isTextbookPlan);
-
-            String isSecd = dto.getIsSecd();
-            Integer isSecdI = Optional.ofNullable(isSecd)
-                    .filter("是"::equals)
-                    .map(s -> 1)
-                    .orElse(0);
-            textbook.setIsSecd(isSecdI);
+            // 处理是否字段
+            if(validateAndSetBooleanField(dto::getIsTextbookPlanCn,
+                    "规划教材(是或否)",
+                    textbook::setIsTextbookPlan,
+                    sb,
+                    i + 3
+            )){
+                return sb.toString();
+            }
+            if(validateAndSetBooleanField(dto::getIsSecd,
+                    "是否为校企合作教材(是或否)",
+                    textbook::setIsSecd,
+                    sb,
+                    i + 3
+            )){
+                return sb.toString();
+            }
+
+            // 处理枚举字段
+            Map<String, Integer> useTypeMap = new HashMap<>();
+            for (UseSemesterTypeEnum useSemesterTypeEnum : UseSemesterTypeEnum.values()) {
+                useTypeMap.put(useSemesterTypeEnum.getValue(), useSemesterTypeEnum.getCode());
+            }
+            if(validateAndSetEnumField(dto::getUseTypeCn,
+                    "使用时长(一学期~六学期)",
+                    useTypeMap,
+                    textbook::setUseType,
+                    sb,
+                    i + 3
+            )){
+                return sb.toString();
+            }
 
             // 判断导入的教材是否已经存在,根据教材的 ISSN 码和使用的学科组和课程判断
             LambdaQueryWrapper<Textbook> textbookLambdaQueryWrapper = new LambdaQueryWrapper<>();
             textbookLambdaQueryWrapper
                     .eq(Textbook::getIssn, textbook.getIssn())
-                    .eq(Textbook::getSubjectGroupId, textbook.getSubjectGroupId())
-                    .eq(Textbook::getCourseSubjectId, textbook.getCourseSubjectId())
                     .eq(Textbook::getDeleteMark, DeleteMark.NODELETE.getCode())
             ;
 
             Textbook verifyTextbook = this.getOne(textbookLambdaQueryWrapper);
 
             textbook.setIsbn(textbook.getIssn());
+            BigDecimal discount =  BigDecimal.valueOf(textbook.getDiscount()).divide( BigDecimal.valueOf(10));
+            textbook.setDiscountPrice(textbook.getPrice().multiply(discount));
             if(ObjectUtils.isNotEmpty(verifyTextbook)){
                 textbook.setId(verifyTextbook.getId());
                 updateTextbooks.add(textbook);

+ 5 - 2
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookWarehouseRecordServiceImpl.java

@@ -37,14 +37,17 @@ public class TextbookWarehouseRecordServiceImpl extends MPJBaseServiceImpl<Textb
     private final TextbookWarehouseRecordMapper textbookWarehouseRecordMapper;
 
     @Override
-    public Page<TextbookWarehouseRecordPageVo> getPage(Page<TextbookWarehouseRecordPageDto> page, TextbookWarehouseRecordPageDto dto) {
+    public Page<TextbookWarehouseRecordPageVo> getPage(TextbookWarehouseRecordPageDto dto) {
+//        MPJLambdaWrapper<TextbookWarehouseRecord>;-
+
 //        MPJLambdaWrapper<TextbookWarehouseRecord> textbookWarehouseRecordMPJLambdaWrapper = new MPJLambdaWrapper<>();
 //        textbookWarehouseRecordMPJLambdaWrapper
 //                .leftJoin()
 //                ;
 
 
-        return textbookWarehouseRecordMapper.getPage(page, dto);
+//        return textbookWarehouseRecordMapper.getPage(page, dto);
+        return null;
     }
 
     @Override

+ 0 - 1
src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookClaimServiceImpl.java

@@ -275,7 +275,6 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
                 int sortCode = SortCodeUtil.getMaxSortCode(textbookIssueRecordMapper, TextbookIssueRecord.class, "sort_code");
 
                 setSortCode(sortCode + 1);
-
             }});
 
             //更新申领项中的已经发放数量

+ 45 - 5
src/main/java/com/xjrsoft/module/veb/util/ImportExcelUtil.java

@@ -1,5 +1,7 @@
 package com.xjrsoft.module.veb.util;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -17,6 +19,7 @@ import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
+import javax.naming.directory.InvalidAttributesException;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -76,6 +79,7 @@ public class ImportExcelUtil {
         Class<?> clazz = obj.getClass();
         Field[] fields = clazz.getDeclaredFields();
 
+        int index = 0;
         for (int i = 0; i < fields.length; i++) {
             Field field = fields[i];
             ImportConfig importConfig = new ImportConfig();
@@ -91,8 +95,12 @@ public class ImportExcelUtil {
                 String[] annotationValues = excelProperty.value();
                 importConfig.setLabel(annotationValues.length > 0 ? annotationValues[0] : "");
             }
+
+            if (field.isAnnotationPresent(ExcelIgnore.class)) {
+                continue;
+            }
             importConfig.setFieldName(field.getName());
-            importConfig.setSortCode(i);
+            importConfig.setSortCode(index++);
             importConfig.setWidth(0);
             importConfigs.add(importConfig);
         }
@@ -191,7 +199,7 @@ public class ImportExcelUtil {
                 return false;
             } else {
                 sb.append("第");
-                sb.append(i + 2);
+                sb.append(i);
                 sb.append("行的");
                 sb.append(fieldName);
                 sb.append("列的值不存在于系统对应基础数据中,请到基础数据维护");
@@ -222,7 +230,7 @@ public class ImportExcelUtil {
                 return false;
             } else {
                 sb.append("第");
-                sb.append(i + 2);
+                sb.append(i);
                 sb.append("行的");
                 sb.append(fieldName);
                 sb.append("列的值不符合,该列的值只能为是或否");
@@ -257,7 +265,7 @@ public class ImportExcelUtil {
                 return false;
             } else {
                 sb.append("第");
-                sb.append(i + 2);
+                sb.append(i);
                 sb.append("行的");
                 sb.append(fieldName);
                 sb.append("列的值不存在于字典中,请到字典中维护");
@@ -267,6 +275,38 @@ public class ImportExcelUtil {
         return false; // 字段为空,不进行验证
     }
 
+    /**
+     * 验证枚举值的合理性并转换为枚举的code
+     * @param getter
+     * @param fieldName
+     * @param setter
+     * @param sb
+     * @param i
+     * @return
+     */
+    public static <E extends Enum<E>> boolean validateAndSetEnumField(Supplier<String> getter,
+                                                        String fieldName,
+                                                        Map<String, Integer> enumMap,
+                                                        Consumer<Integer> setter,
+                                                        StringBuilder sb, int i) {
+        String value = getter.get();
+        if (value != null && !value.trim().isEmpty()) {
+            Integer enumValue = enumMap.get(value);
+            if (enumValue != null) {
+                setter.accept(enumValue);
+                return false;
+            } else {
+                sb.append("第");
+                sb.append(i);
+                sb.append("行的");
+                sb.append(fieldName);
+                sb.append("列的值不存在于枚举值中,请到枚举值中维护");
+                return true;
+            }
+        }
+        return false; // 字段为空,不进行验证
+    }
+
     /**
      * 获取所有的字典值映射
      * @param codeList
@@ -320,7 +360,7 @@ public class ImportExcelUtil {
                 Object value = field.get(instance); // 获取字段的值
                 if (value == null || (value instanceof String && ((String) value).trim().isEmpty())) {
                     sb.append("第");
-                    sb.append(i + 2);
+                    sb.append(i);
                     sb.append("行的");
                     if (field.isAnnotationPresent(ExcelProperty.class)) {
                         ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);

+ 10 - 1
src/main/resources/mapper/base/BaseClassCourse.xml

@@ -36,7 +36,16 @@
         <if test="dto.semester != null">
             AND t5.base_semester_id = #{dto.semester}
         </if>
-        ) AS total_price
+        ) AS total_price,
+        (SELECT sum(t8.discount_price)
+        FROM base_class_course t5
+        LEFT JOIN textbook t8 ON t8.id = t5.textbook_id
+        WHERE t5.class_id = t.id
+        AND t5.delete_mark = 0
+        <if test="dto.semester != null">
+            AND t5.base_semester_id = #{dto.semester}
+        </if>
+        ) AS count
         FROM base_class t
         LEFT JOIN xjr_user t1 ON t1.id = t.teacher_id
         LEFT JOIN base_class_major_set t2 ON t2.class_id = t.id

+ 42 - 41
src/main/resources/sqlScript/textbook_sql.sql

@@ -20,7 +20,7 @@ create table `textbook`
     use_type              int            null default 1 comment '使用类型(单位:学期)',
 
     issn                  varchar(200)   not null unique comment '国际标准刊号',
-    isbn                  varchar(200)   not null unique comment '国际标准书号',
+    isbn                  varchar(200)   null unique comment '国际标准书号',
     book_name             varchar(200)   not null comment '书名',
     publishing_house      varchar(200)   null default '/' comment '出版社',
     editor_in_chief       varchar(200)   null default '/' comment '主编',
@@ -28,14 +28,15 @@ create table `textbook`
     is_textbook_plan      int            null default 0 comment '是否为规划教材',
     textbook_type         varchar(20)    null comment '教材分类(xjr_dictionary_item[textbook_type])',
     specifications_models varchar(100)   null default '/' comment '规格型号',
-    publishing_date       date       null comment '出版日期',
+    publishing_date       date           null comment '出版日期',
     is_secd               int            null default 0 comment '是否校企合作开发教材',
     category              varchar(50)    null default '/' comment '分类号',
     plan_batch            varchar(50)    null default '/' comment '规划批次',
     work_total_count      int            null default 0 comment '编著作总数',
     textbook_category     varchar(30)    null default '/' comment '教材类型',
     price                 decimal(10, 2) null default 0 comment '定价(元)',
-    discount              float          null default 10 comment '预估折扣'
+    discount              float          null default 10 comment '预估折扣',
+    discount_price        decimal(10, 2) null default 0 comment '预估折扣后价格(元)'
 ) engine = innodb
   default charset = utf8mb4
   collate = utf8mb4_0900_ai_ci comment ='教材基础信息表';
@@ -187,9 +188,9 @@ create table `textbook_warehouse_record`
     total_price      decimal(10, 2) null comment '总价(元)',
 
     remark           varchar(1000)  null comment '备注'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='教材入库记录';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='教材入库记录';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -222,9 +223,9 @@ create table `wf_textbook_claim`
 
 
     status            int default 0 not null comment '状态(1:结束 0:未结束)'
-)engine = innodb
-    default charset = utf8mb4
-    collate = utf8mb4_0900_ai_ci comment ='教材申领';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='教材申领';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -247,9 +248,9 @@ create table `wf_textbook_claim_item`
     textbook_id          bigint        null comment '教材管理编号',
     applicant_number     int default 0 null comment '申请数量',
     issue_number         int default 0 null comment '已发放数量'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='教材申领项';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='教材申领项';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -258,22 +259,22 @@ create table `wf_textbook_claim_item`
 drop table if exists claim_item_subscription_item;
 create table `claim_item_subscription_item`
 (
-    id                   bigint        not null comment '主键编号'
+    id                            bigint        not null comment '主键编号'
         primary key,
-    create_user_id       bigint        null comment '创建人',
-    create_date          datetime      null comment '创建时间',
-    modify_user_id       bigint        null comment '修改人',
-    modify_date          datetime      null comment '修改时间',
-    delete_mark          int           not null comment '删除标记',
-    enabled_mark         int           not null comment '有效标志',
-    sort_code            int           null comment '序号',
-
-    wf_textbook_claim_item_id bigint        null comment '教材申领编号',
+    create_user_id                bigint        null comment '创建人',
+    create_date                   datetime      null comment '创建时间',
+    modify_user_id                bigint        null comment '修改人',
+    modify_date                   datetime      null comment '修改时间',
+    delete_mark                   int           not null comment '删除标记',
+    enabled_mark                  int           not null comment '有效标志',
+    sort_code                     int           null comment '序号',
+
+    wf_textbook_claim_item_id     bigint        null comment '教材申领编号',
     textbook_subscription_item_id bigint        null comment '教材征订编号',
-    issue_number         int default 0 null comment '已发放数量'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='教材申领项与教材征订项关联表';
+    issue_number                  int default 0 null comment '已发放数量'
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='教材申领项与教材征订项关联表';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -296,9 +297,9 @@ create table `textbook_claim_user`
 
     user_id              bigint        null comment '用户编号',
     user_type            int default 2 null comment '用户类型(1:学生 2=教师)'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='教材领取人员';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='教材领取人员';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -329,9 +330,9 @@ create table `textbook_issue_record`
     issue_user_id    bigint        null comment '出库用户编号',
 
     remark           varchar(1000) null comment '备注'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='教材出库记录';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='教材出库记录';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -357,9 +358,9 @@ create table `textbook_student_claim`
     textbook_id      bigint        null comment '教材管理编号',
     is_claim         int default 0 not null comment '是否领取(1:已领取 0:未领取)',
     remark           varchar(1000) null comment '备注'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='学生教材认领记录';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='学生教材认领记录';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -386,9 +387,9 @@ create table `wf_textbook_recede`
 
     recede_address    varchar(1000) null comment '退还地点',
     status            int default 0 not null comment '状态(1:结束 0:未结束)'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='退书申请';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='退书申请';
 
 -- ----------------------------
 -- 2024-12-13 14:36
@@ -411,9 +412,9 @@ create table `wf_textbook_recede_item`
 
     textbook_id           bigint   null comment '教材管理编号',
     number                int      null comment '数量'
-)engine = innodb
- default charset = utf8mb4
- collate = utf8mb4_0900_ai_ci comment ='退书申请项';
+) engine = innodb
+  default charset = utf8mb4
+  collate = utf8mb4_0900_ai_ci comment ='退书申请项';