Selaa lähdekoodia

3.1.0-bug修改

xiaof 2 vuotta sitten
vanhempi
commit
d88bd9c159

+ 69 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/ExamStudentCourseClassDto.java

@@ -0,0 +1,69 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import com.qmth.distributed.print.business.entity.ExamStudent;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 考生科目 dto
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2021/5/14
+ */
+public class ExamStudentCourseClassDto extends ExamStudent {
+
+    @ApiModelProperty(value = "科目编码")
+    private String courseCode;
+
+    @ApiModelProperty(value = "科目名称")
+    private String courseName;
+
+    @ApiModelProperty("试卷编号")
+    private String paperNumber;
+
+    @ApiModelProperty("任课老师")
+    private String teacherName;
+
+    @ApiModelProperty("任课老师工号")
+    private String teacherNumber;
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
+
+    public String getTeacherNumber() {
+        return teacherNumber;
+    }
+
+    public void setTeacherNumber(String teacherNumber) {
+        this.teacherNumber = teacherNumber;
+    }
+}

+ 87 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/GradeBatchStudentClazzDto.java

@@ -0,0 +1,87 @@
+package com.qmth.distributed.print.business.bean.dto;
+
+import com.qmth.teachcloud.common.annotation.ExcelImportTempleteVaild;
+
+/**
+ * <p>
+ * 考务数据班级(包含任课老师)
+ * </p>
+ *
+ * @since 2022-07-14
+ */
+@ExcelImportTempleteVaild(value = true)
+public class GradeBatchStudentClazzDto {
+
+    private String courseCode;
+    private String courseName;
+    private String paperNumber;
+    private String paperType;
+    private String clazzId;
+    private String clazzName;
+    private String teacherName;
+    private String teacherNumber;
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public String getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(String clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public String getClazzName() {
+        return clazzName;
+    }
+
+    public void setClazzName(String clazzName) {
+        this.clazzName = clazzName;
+    }
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
+
+    public String getTeacherNumber() {
+        return teacherNumber;
+    }
+
+    public void setTeacherNumber(String teacherNumber) {
+        this.teacherNumber = teacherNumber;
+    }
+}

+ 122 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/GradeBatchStudentClazz.java

@@ -0,0 +1,122 @@
+package com.qmth.distributed.print.business.entity;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.teachcloud.common.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 考务数据班级(包含任课老师)
+ * </p>
+ *
+ * @since 2022-07-14
+ */
+@ApiModel(value = "GradeBatchStudentClazz对象", description = "考务数据班级(包含任课老师)")
+public class GradeBatchStudentClazz extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "分析-批次表ID")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long batchId;
+
+    @ApiModelProperty(value = "课程编码")
+    private String courseCode;
+
+    @ApiModelProperty(value = "课程名称")
+    private String courseName;
+
+    @ApiModelProperty(value = "试卷编号")
+    private String paperNumber;
+
+    @ApiModelProperty(value = "试卷类型")
+    private String paperType;
+
+    @ApiModelProperty(value = "班级ID")
+    private String clazzId;
+
+    @ApiModelProperty(value = "班级名称")
+    private String clazzName;
+
+    @ApiModelProperty(value = "任课老师")
+    private String teacherName;
+
+    @ApiModelProperty(value = "任课老师工号")
+    private String teacherNumber;
+
+    public Long getBatchId() {
+        return batchId;
+    }
+
+    public void setBatchId(Long batchId) {
+        this.batchId = batchId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperNumber() {
+        return paperNumber;
+    }
+
+    public void setPaperNumber(String paperNumber) {
+        this.paperNumber = paperNumber;
+    }
+
+    public String getPaperType() {
+        return paperType;
+    }
+
+    public void setPaperType(String paperType) {
+        this.paperType = paperType;
+    }
+
+    public String getClazzId() {
+        return clazzId;
+    }
+
+    public void setClazzId(String clazzId) {
+        this.clazzId = clazzId;
+    }
+
+    public String getClazzName() {
+        return clazzName;
+    }
+
+    public void setClazzName(String clazzName) {
+        this.clazzName = clazzName;
+    }
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
+
+    public String getTeacherNumber() {
+        return teacherNumber;
+    }
+
+    public void setTeacherNumber(String teacherNumber) {
+        this.teacherNumber = teacherNumber;
+    }
+}

+ 2 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/ExamStudentMapper.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.mapper;
 package com.qmth.distributed.print.business.mapper;
 
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentPdfInfoDto;
 import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
 import com.qmth.distributed.print.business.bean.dto.SyncExamStudentDto;
@@ -50,5 +51,5 @@ public interface ExamStudentMapper extends BaseMapper<ExamStudent> {
 
 
     List<Map> listStudentScoreSync(@Param("schoolId") Long schoolId, @Param("studentCode") String studentCode, @Param("examNumber") String examNumber, @Param("subjectCode") String subjectCode, @Param("printPlanId") Long printPlanId);
     List<Map> listStudentScoreSync(@Param("schoolId") Long schoolId, @Param("studentCode") String studentCode, @Param("examNumber") String examNumber, @Param("subjectCode") String subjectCode, @Param("printPlanId") Long printPlanId);
 
 
-    List<ExamStudentCourseDto> listExamStudentByPaperNumberAndPaperType(@Param("paperNumber") String paperNumber, @Param("paperType") String paperType);
+    List<ExamStudentCourseClassDto> listExamStudentByPaperNumberAndPaperType(@Param("paperNumber") String paperNumber, @Param("paperType") String paperType);
 }
 }

+ 13 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/GradeBatchStudentClazzMapper.java

@@ -0,0 +1,13 @@
+package com.qmth.distributed.print.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.distributed.print.business.entity.GradeBatchStudentClazz;
+
+/**
+ * <p>
+ * 考试字典表 Mapper 接口
+ * </p>
+ */
+public interface GradeBatchStudentClazzMapper extends BaseMapper<GradeBatchStudentClazz> {
+
+}

+ 14 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/GradeBatchStudentClazzService.java

@@ -0,0 +1,14 @@
+package com.qmth.distributed.print.business.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.entity.GradeBatchStudentClazz;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @since 2022-05-20
+ */
+public interface GradeBatchStudentClazzService extends IService<GradeBatchStudentClazz> {
+
+}

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java

@@ -466,15 +466,15 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
     @Override
     @Override
     public void syncDataCloudBatch(SyncDataParam syncDataParam) {
     public void syncDataCloudBatch(SyncDataParam syncDataParam) {
         List<Long> ids = syncDataParam.getList();
         List<Long> ids = syncDataParam.getList();
-        if (ids == null || ids.size() == 0) {
+        if (ids.isEmpty()) {
             throw ExceptionResultEnum.ERROR.exception("请选择操作数据");
             throw ExceptionResultEnum.ERROR.exception("请选择操作数据");
         }
         }
         QueryWrapper<ExamPrintPlan> queryWrapper = new QueryWrapper<>();
         QueryWrapper<ExamPrintPlan> queryWrapper = new QueryWrapper<>();
         List<PrintPlanStatusEnum> statusEnums = Arrays.asList(PrintPlanStatusEnum.END, PrintPlanStatusEnum.PRINT_FINISH);
         List<PrintPlanStatusEnum> statusEnums = Arrays.asList(PrintPlanStatusEnum.END, PrintPlanStatusEnum.PRINT_FINISH);
         queryWrapper.lambda().in(ExamPrintPlan::getId, ids);
         queryWrapper.lambda().in(ExamPrintPlan::getId, ids);
         List<ExamPrintPlan> examPrintPlans = this.list(queryWrapper);
         List<ExamPrintPlan> examPrintPlans = this.list(queryWrapper);
-        if (examPrintPlans != null && examPrintPlans.size() > 0) {
-            long count = examPrintPlans.stream().filter(m -> statusEnums.indexOf(m.getStatus()) > 0).count();
+        if (!examPrintPlans.isEmpty()) {
+            long count = examPrintPlans.stream().filter(m -> !statusEnums.contains(m.getStatus())).count();
             if (count > 0) {
             if (count > 0) {
                 throw ExceptionResultEnum.ERROR.exception("印刷计划未打印完成或者未结束,不能同步数据");
                 throw ExceptionResultEnum.ERROR.exception("印刷计划未打印完成或者未结束,不能同步数据");
             }
             }

+ 132 - 68
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchServiceImpl.java

@@ -8,20 +8,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
+import com.qmth.distributed.print.business.bean.dto.GradeBatchStudentClazzDto;
 import com.qmth.distributed.print.business.bean.dto.GradeBatchStudentDto;
 import com.qmth.distributed.print.business.bean.dto.GradeBatchStudentDto;
 import com.qmth.distributed.print.business.bean.params.analyze.GradeBatchParam;
 import com.qmth.distributed.print.business.bean.params.analyze.GradeBatchParam;
 import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchResult;
 import com.qmth.distributed.print.business.bean.result.analyze.GradeBatchResult;
-import com.qmth.distributed.print.business.entity.ExamTask;
-import com.qmth.distributed.print.business.entity.GradeBatch;
-import com.qmth.distributed.print.business.entity.GradeBatchPaper;
-import com.qmth.distributed.print.business.entity.GradeBatchStudent;
+import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.mapper.ExamStudentMapper;
 import com.qmth.distributed.print.business.mapper.ExamStudentMapper;
 import com.qmth.distributed.print.business.mapper.GradeBatchMapper;
 import com.qmth.distributed.print.business.mapper.GradeBatchMapper;
-import com.qmth.distributed.print.business.service.ExamTaskService;
-import com.qmth.distributed.print.business.service.GradeBatchPaperService;
-import com.qmth.distributed.print.business.service.GradeBatchService;
-import com.qmth.distributed.print.business.service.GradeBatchStudentService;
+import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -37,7 +33,8 @@ import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -71,6 +68,9 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
     @Resource
     @Resource
     GradeBatchStudentService gradeBatchStudentService;
     GradeBatchStudentService gradeBatchStudentService;
 
 
+    @Resource
+    GradeBatchStudentClazzService gradeBatchStudentClazzService;
+
     @Resource
     @Resource
     TeachcloudCommonService teachcloudCommonService;
     TeachcloudCommonService teachcloudCommonService;
 
 
@@ -182,11 +182,11 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
             throw ExceptionResultEnum.ERROR.exception("请先添加分析课程");
             throw ExceptionResultEnum.ERROR.exception("请先添加分析课程");
         }
         }
 
 
-        List<ExamStudentCourseDto> finalList = new ArrayList<>();
+        List<ExamStudentCourseClassDto> finalList = new ArrayList<>();
         for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
         for (GradeBatchPaper gradeBatchPaper : gradeBatchPaperList) {
-            List<ExamStudentCourseDto> examStudentList = examStudentMapper.listExamStudentByPaperNumberAndPaperType(gradeBatchPaper.getPaperNumber(), gradeBatchPaper.getPaperType());
-            if (!examStudentList.isEmpty()) {
-                finalList.addAll(examStudentList);
+            List<ExamStudentCourseClassDto> examStudentClassList = examStudentMapper.listExamStudentByPaperNumberAndPaperType(gradeBatchPaper.getPaperNumber(), gradeBatchPaper.getPaperType());
+            if (!examStudentClassList.isEmpty()) {
+                finalList.addAll(examStudentClassList);
             }
             }
         }
         }
 
 
@@ -194,50 +194,117 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
             throw ExceptionResultEnum.ERROR.exception("分析课程下没有考务数据");
             throw ExceptionResultEnum.ERROR.exception("分析课程下没有考务数据");
         }
         }
 
 
-        String fileName = gradeBatch.getBatchName() + "考务数据.xlsx";
+        String fileName = gradeBatch.getBatchName() + "任课老师填写模板.xlsx";
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFWorkbook wb = new XSSFWorkbook();
-        XSSFSheet sheet = wb.createSheet("考务数据");
-        XSSFFont font = wb.createFont();
-        font.setFontHeightInPoints((short) 11);
-        font.setFontName("宋体"); //什么字体
+        XSSFSheet sheet = wb.createSheet("数据");
 
 
-        XSSFRow headRow = sheet.createRow(0);
-        XSSFCellStyle style = wb.createCellStyle();
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setFont(font);
+        // 表头
+        CellStyle headerStyle = wb.createCellStyle();
+        headerStyle.setAlignment(HorizontalAlignment.CENTER);
+        headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        headerStyle.setBorderRight(BorderStyle.THIN);
+        headerStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        headerStyle.setBorderLeft(BorderStyle.THIN);
+        headerStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        headerStyle.setBorderTop(BorderStyle.THIN);
+        headerStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        headerStyle.setBorderBottom(BorderStyle.THIN);
+        headerStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        // 背景颜色
+        headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
+        Font font = wb.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setFontName("宋体");
+        font.setColor(IndexedColors.WHITE.getIndex());
+        headerStyle.setFont(font);
+
+        // 数据
+        XSSFCellStyle dataStyle = wb.createCellStyle();
+        dataStyle.setAlignment(HorizontalAlignment.CENTER);
+        dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        dataStyle.setBorderRight(BorderStyle.THIN);
+        dataStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setBorderLeft(BorderStyle.THIN);
+        dataStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setBorderTop(BorderStyle.THIN);
+        dataStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setBorderBottom(BorderStyle.THIN);
+        dataStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
+        dataStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        // 背景颜色
+        dataStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
+        font = wb.createFont();
+        font.setFontHeightInPoints((short) 10);
+        font.setFontName("宋体");
+        dataStyle.setFont(font);
+
+        // 锁定样式
+        XSSFCellStyle lockStyle = wb.createCellStyle();
+        lockStyle.setLocked(true);//设置锁定
+
+        // 未锁定样式
+        XSSFCellStyle unlockStyle=wb.createCellStyle();
+        unlockStyle.setLocked(false);//设置未锁定
 
 
+        XSSFRow headRow = sheet.createRow(0);
         // 表头
         // 表头
-        String[] fieldsNameList = {"课程代码", "课程名称", "试卷编号", "试卷类型", "学号", "学生姓名", "准考证号", "任课老师", "任课老师工号"};
+        String[] fieldsNameList = {"课程代码", "课程名称", "试卷编号", "试卷类型", "班级ID", "班级名称", "任课老师", "任课老师工号"};
         for (int i = 0; i < fieldsNameList.length; i++) {
         for (int i = 0; i < fieldsNameList.length; i++) {
             XSSFCell cell = headRow.createCell(i);
             XSSFCell cell = headRow.createCell(i);
             cell.setCellValue(fieldsNameList[i]);
             cell.setCellValue(fieldsNameList[i]);
-            cell.setCellStyle(style);
+            cell.setCellStyle(headerStyle);
         }
         }
+
         for (int i = 1; i <= finalList.size(); i++) {
         for (int i = 1; i <= finalList.size(); i++) {
-            ExamStudentCourseDto examStudentCourseDto = finalList.get(i - 1);
+            ExamStudentCourseClassDto examStudentCourseDto = finalList.get(i - 1);
             XSSFRow row = sheet.createRow(i);
             XSSFRow row = sheet.createRow(i);
+
             XSSFCell cell0 = row.createCell(0);
             XSSFCell cell0 = row.createCell(0);
+            cell0.setCellStyle(lockStyle);
+            cell0.setCellStyle(dataStyle);
             cell0.setCellValue(examStudentCourseDto.getCourseCode());
             cell0.setCellValue(examStudentCourseDto.getCourseCode());
 
 
             XSSFCell cell1 = row.createCell(1);
             XSSFCell cell1 = row.createCell(1);
+            cell1.setCellStyle(lockStyle);
+            cell1.setCellStyle(dataStyle);
             cell1.setCellValue(examStudentCourseDto.getCourseName());
             cell1.setCellValue(examStudentCourseDto.getCourseName());
 
 
             XSSFCell cell2 = row.createCell(2);
             XSSFCell cell2 = row.createCell(2);
+            cell2.setCellStyle(lockStyle);
+            cell2.setCellStyle(dataStyle);
             cell2.setCellValue(examStudentCourseDto.getPaperNumber());
             cell2.setCellValue(examStudentCourseDto.getPaperNumber());
 
 
             XSSFCell cell3 = row.createCell(3);
             XSSFCell cell3 = row.createCell(3);
+            cell3.setCellStyle(lockStyle);
+            cell3.setCellStyle(dataStyle);
             cell3.setCellValue(examStudentCourseDto.getPaperType());
             cell3.setCellValue(examStudentCourseDto.getPaperType());
 
 
             XSSFCell cell4 = row.createCell(4);
             XSSFCell cell4 = row.createCell(4);
-            cell4.setCellValue(examStudentCourseDto.getStudentCode());
+            cell4.setCellStyle(lockStyle);
+            cell4.setCellStyle(dataStyle);
+            cell4.setCellValue(examStudentCourseDto.getClazzId());
 
 
             XSSFCell cell5 = row.createCell(5);
             XSSFCell cell5 = row.createCell(5);
-            cell5.setCellValue(examStudentCourseDto.getStudentName());
+            cell5.setCellStyle(lockStyle);
+            cell5.setCellStyle(dataStyle);
+            cell5.setCellValue(examStudentCourseDto.getClazzName());
 
 
             XSSFCell cell6 = row.createCell(6);
             XSSFCell cell6 = row.createCell(6);
-            cell6.setCellValue(examStudentCourseDto.getTicketNumber());
+            cell6.setCellStyle(unlockStyle);
+
+            XSSFCell cell7 = row.createCell(7);
+            cell7.setCellStyle(unlockStyle);
+        }
+
+        for (int i = 0; i < fieldsNameList.length; i++) {
+            sheet.autoSizeColumn(i);
+            sheet.setColumnWidth(i,sheet.getColumnWidth(i)*17/10);
         }
         }
 
 
+        // sheet添加保护,这个一定要否则光锁定还是可以编辑的
+        sheet.protectSheet("Qmth87863577");
+
         OutputStream output = response.getOutputStream();
         OutputStream output = response.getOutputStream();
         response.reset();
         response.reset();
         response.setCharacterEncoding("ISO-8859-1");
         response.setCharacterEncoding("ISO-8859-1");
@@ -250,9 +317,9 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
 
 
     @Override
     @Override
     public void uploadFile(Long batchId, MultipartFile file) throws IOException, NoSuchFieldException {
     public void uploadFile(Long batchId, MultipartFile file) throws IOException, NoSuchFieldException {
-        List<GradeBatchStudentDto> list = new ArrayList<>();
+        List<GradeBatchStudentClazzDto> list = new ArrayList<>();
         Map<String, String> teacherMap = new HashMap<>();
         Map<String, String> teacherMap = new HashMap<>();
-        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradeBatchStudentDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradeBatchStudentClazzDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
             List<ExcelError> excelErrorTemp = new ArrayList<>();
             List<ExcelError> excelErrorTemp = new ArrayList<>();
             // 只允许导入一个sheet
             // 只允许导入一个sheet
             if (finalExcelList.size() > 1) {
             if (finalExcelList.size() > 1) {
@@ -263,33 +330,30 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
                 LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
                 LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
                 List<Object> gradeBatchStudentTempList = excelMap.get(i);
                 List<Object> gradeBatchStudentTempList = excelMap.get(i);
                 for (int y = 0; y < Objects.requireNonNull(gradeBatchStudentTempList).size(); y++) {
                 for (int y = 0; y < Objects.requireNonNull(gradeBatchStudentTempList).size(); y++) {
-                    GradeBatchStudentDto examStudentCourseDto = (GradeBatchStudentDto) gradeBatchStudentTempList.get(y);
-                    if (StringUtils.isBlank(examStudentCourseDto.getCourseCode())) {
+                    GradeBatchStudentClazzDto gradeBatchStudentClazzDto = (GradeBatchStudentClazzDto) gradeBatchStudentTempList.get(y);
+                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getCourseCode())) {
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程代码]必填"));
                     }
                     }
-                    if (StringUtils.isBlank(examStudentCourseDto.getCourseName())) {
+                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getCourseName())) {
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]必填"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]必填"));
                     }
                     }
-                    if (StringUtils.isBlank(examStudentCourseDto.getPaperNumber())) {
+                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getPaperNumber())) {
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷编号]必填"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷编号]必填"));
                     }
                     }
-                    if (StringUtils.isBlank(examStudentCourseDto.getPaperType())) {
+                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getPaperType())) {
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷类型]必填"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[试卷类型]必填"));
                     }
                     }
-                    if (StringUtils.isBlank(examStudentCourseDto.getStudentCode())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[学号]必填"));
-                    }
-                    if (StringUtils.isBlank(examStudentCourseDto.getStudentName())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[学生姓名]必填"));
+                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getClazzId())) {
+                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[班级ID]必填"));
                     }
                     }
-                    if (StringUtils.isBlank(examStudentCourseDto.getTicketNumber())) {
-                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[准考证号]必填"));
+                    if (StringUtils.isBlank(gradeBatchStudentClazzDto.getClazzName())) {
+                        excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[班级名称]必填"));
                     }
                     }
-                    String teacherName = examStudentCourseDto.getTeacherName();
+                    String teacherName = gradeBatchStudentClazzDto.getTeacherName();
                     if (StringUtils.isBlank(teacherName)) {
                     if (StringUtils.isBlank(teacherName)) {
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师]必填"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师]必填"));
                     }
                     }
-                    String teacherNumber = examStudentCourseDto.getTeacherNumber();
+                    String teacherNumber = gradeBatchStudentClazzDto.getTeacherNumber();
                     if (StringUtils.isBlank(teacherNumber)) {
                     if (StringUtils.isBlank(teacherNumber)) {
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师工号]必填"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[任课老师工号]必填"));
                     }
                     }
@@ -297,9 +361,9 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
                         excelErrorTemp.add(new ExcelError(y + 1, "excel中同一个任课老师工号有多个姓名"));
                         excelErrorTemp.add(new ExcelError(y + 1, "excel中同一个任课老师工号有多个姓名"));
                     }
                     }
 
 
-                    teacherMap.put(examStudentCourseDto.getTeacherNumber(), examStudentCourseDto.getTeacherName());
+                    teacherMap.put(gradeBatchStudentClazzDto.getTeacherNumber(), gradeBatchStudentClazzDto.getTeacherName());
 
 
-                    list.add(examStudentCourseDto);
+                    list.add(gradeBatchStudentClazzDto);
                 }
                 }
             }
             }
 
 
@@ -395,27 +459,27 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
     }
     }
 
 
     @Transactional
     @Transactional
-    public void executeImportGradeBatchStudent(Long batchId, List<GradeBatchStudentDto> list) {
-        UpdateWrapper<GradeBatchStudent> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().eq(GradeBatchStudent::getBatchId, batchId);
-        gradeBatchStudentService.remove(updateWrapper);
-
-        List<GradeBatchStudent> gradeBatchStudents = list.stream().map(m -> {
-            GradeBatchStudent gradeBatchStudent = new GradeBatchStudent();
-            gradeBatchStudent.setBatchId(SystemConstant.getDbUuid());
-            gradeBatchStudent.setBatchId(batchId);
-            gradeBatchStudent.setCourseCode(m.getCourseCode());
-            gradeBatchStudent.setCourseName(m.getCourseName());
-            gradeBatchStudent.setPaperNumber(m.getPaperNumber());
-            gradeBatchStudent.setPaperType(m.getPaperType());
-            gradeBatchStudent.setStudentCode(m.getStudentCode());
-            gradeBatchStudent.setStudentName(m.getStudentName());
-            gradeBatchStudent.setTeacherName(m.getTeacherName());
-            gradeBatchStudent.setTeacherNumber(m.getTeacherNumber());
-            return gradeBatchStudent;
+    public void executeImportGradeBatchStudent(Long batchId, List<GradeBatchStudentClazzDto> list) {
+        UpdateWrapper<GradeBatchStudentClazz> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(GradeBatchStudentClazz::getBatchId, batchId);
+        gradeBatchStudentClazzService.remove(updateWrapper);
+
+        List<GradeBatchStudentClazz> gradeBatchStudentClazzes = list.stream().map(m -> {
+            GradeBatchStudentClazz gradeBatchStudentClazz = new GradeBatchStudentClazz();
+            gradeBatchStudentClazz.setId(SystemConstant.getDbUuid());
+            gradeBatchStudentClazz.setBatchId(batchId);
+            gradeBatchStudentClazz.setCourseCode(m.getCourseCode());
+            gradeBatchStudentClazz.setCourseName(m.getCourseName());
+            gradeBatchStudentClazz.setPaperNumber(m.getPaperNumber());
+            gradeBatchStudentClazz.setPaperType(m.getPaperType());
+            gradeBatchStudentClazz.setClazzId(m.getClazzId());
+            gradeBatchStudentClazz.setClazzName(m.getClazzName());
+            gradeBatchStudentClazz.setTeacherName(m.getTeacherName());
+            gradeBatchStudentClazz.setTeacherNumber(m.getTeacherNumber());
+            return gradeBatchStudentClazz;
         }).collect(Collectors.toList());
         }).collect(Collectors.toList());
 
 
-        gradeBatchStudentService.saveBatch(gradeBatchStudents);
+        gradeBatchStudentClazzService.saveBatch(gradeBatchStudentClazzes);
 
 
         GradeBatch gradeBatch = this.getById(batchId);
         GradeBatch gradeBatch = this.getById(batchId);
 
 
@@ -430,10 +494,10 @@ public class GradeBatchServiceImpl extends ServiceImpl<GradeBatchMapper, GradeBa
         if (sysRoleList.isEmpty()) {
         if (sysRoleList.isEmpty()) {
             throw ExceptionResultEnum.SUCCESS.exception("未找到任课老师角色,请联系管理员");
             throw ExceptionResultEnum.SUCCESS.exception("未找到任课老师角色,请联系管理员");
         }
         }
-        Map<String, List<GradeBatchStudentDto>> listMap = list.stream().collect(Collectors.groupingBy(m -> m.getTeacherNumber() + "##" + m.getTeacherName()));
-        for (Map.Entry<String, List<GradeBatchStudentDto>> entry : listMap.entrySet()) {
+        Map<String, List<GradeBatchStudentClazzDto>> listMap = list.stream().collect(Collectors.groupingBy(m -> m.getTeacherNumber() + "##" + m.getTeacherName()));
+        for (Map.Entry<String, List<GradeBatchStudentClazzDto>> entry : listMap.entrySet()) {
             String[] key = entry.getKey().split("##");
             String[] key = entry.getKey().split("##");
-            List<GradeBatchStudentDto> dtoList = entry.getValue();
+            List<GradeBatchStudentClazzDto> dtoList = entry.getValue();
             List<SysUser> sysUserList = sysUserService.findBySchoolIdAndCode(schoolId, key[0]);
             List<SysUser> sysUserList = sysUserService.findBySchoolIdAndCode(schoolId, key[0]);
             if (!sysUserList.isEmpty() && sysUserList.size() > 1) {
             if (!sysUserList.isEmpty() && sysUserList.size() > 1) {
                 throw ExceptionResultEnum.SUCCESS.exception(key[0] + "找到多条用户记录");
                 throw ExceptionResultEnum.SUCCESS.exception(key[0] + "找到多条用户记录");

+ 21 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/GradeBatchStudentClazzServiceImpl.java

@@ -0,0 +1,21 @@
+package com.qmth.distributed.print.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.distributed.print.business.entity.GradeBatchStudent;
+import com.qmth.distributed.print.business.entity.GradeBatchStudentClazz;
+import com.qmth.distributed.print.business.mapper.GradeBatchStudentClazzMapper;
+import com.qmth.distributed.print.business.mapper.GradeBatchStudentMapper;
+import com.qmth.distributed.print.business.service.GradeBatchStudentClazzService;
+import com.qmth.distributed.print.business.service.GradeBatchStudentService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 考务数据班级 服务实现类
+ * </p>
+ *
+ * @since 2022-05-20
+ */
+@Service
+public class GradeBatchStudentClazzServiceImpl extends ServiceImpl<GradeBatchStudentClazzMapper, GradeBatchStudentClazz> implements GradeBatchStudentClazzService {
+}

+ 4 - 5
distributed-print-business/src/main/resources/mapper/ExamStudentMapper.xml

@@ -224,15 +224,14 @@
           AND CONCAT(b.course_code, a.paper_type, d.sequence) = #{subjectCode}
           AND CONCAT(b.course_code, a.paper_type, d.sequence) = #{subjectCode}
     </select>
     </select>
     <select id="listExamStudentByPaperNumberAndPaperType"
     <select id="listExamStudentByPaperNumberAndPaperType"
-            resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto">
+            resultType="com.qmth.distributed.print.business.bean.dto.ExamStudentCourseClassDto">
         SELECT
         SELECT
-            edc.course_code courseCode,
+            distinct edc.course_code courseCode,
             edc.course_name courseName,
             edc.course_name courseName,
             edc.paper_number paperNumber,
             edc.paper_number paperNumber,
             es.paper_type paperType,
             es.paper_type paperType,
-            es.student_name studentName,
-            es.student_code studentCode,
-            es.ticket_number ticketNumber
+            es.clazz_id clazzId,
+            es.clazz_name clazzName
         FROM
         FROM
             exam_student es
             exam_student es
                 JOIN
                 JOIN

+ 2 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysUserServiceImpl.java

@@ -546,7 +546,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(sysUser.getId());
                 List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(sysUser.getId());
                 List<Long> userRolesList = Arrays.asList(userSaveParams.getRoleIds());
                 List<Long> userRolesList = Arrays.asList(userSaveParams.getRoleIds());
                 Set<Long> dbUserRolesList = sysUserRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet());
                 Set<Long> dbUserRolesList = sysUserRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet());
-                int count = (int) dbUserRolesList.stream().filter(userRolesList::contains).count();
+                int count = (int) dbUserRolesList.stream().filter(s -> !userRolesList.contains(s)).count();
                 Set<Long> removeRoleIds = dbUserRolesList.stream().filter(s -> !userRolesList.contains(s)).collect(Collectors.toSet());
                 Set<Long> removeRoleIds = dbUserRolesList.stream().filter(s -> !userRolesList.contains(s)).collect(Collectors.toSet());
                 SysUser dbUser = sysUserService.getById(sysUser.getId());
                 SysUser dbUser = sysUserService.getById(sysUser.getId());
                 sysUserService.update(new UpdateWrapper<SysUser>().lambda()
                 sysUserService.update(new UpdateWrapper<SysUser>().lambda()
@@ -562,7 +562,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                         .set(SysUser::getUpdateTime, System.currentTimeMillis())
                         .set(SysUser::getUpdateTime, System.currentTimeMillis())
                 );
                 );
                 //如果修改了角色,需要重新登录
                 //如果修改了角色,需要重新登录
-                if (count == 0 || dbUserRolesList.size() != userRolesList.size()) {
+                if (count > 0 || dbUserRolesList.size() != userRolesList.size()) {
                     QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
                     QueryWrapper<SysUserRole> sysUserRoleQueryWrapper = new QueryWrapper<>();
                     sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, sysUser.getId());
                     sysUserRoleQueryWrapper.lambda().eq(SysUserRole::getUserId, sysUser.getId());
                     sysUserRoleService.remove(sysUserRoleQueryWrapper);
                     sysUserRoleService.remove(sysUserRoleQueryWrapper);