Explorar el Código

班级量化考核导出调整

dzx hace 4 semanas
padre
commit
522760fb41

+ 7 - 3
src/main/java/com/xjrsoft/module/student/controller/BaseStudentAssessmentInspectionController.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.student.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.excel.support.ExcelTypeEnum;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xjrsoft.common.model.result.RT;
@@ -34,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.io.IOException;
 import java.util.Date;
 import java.util.List;
 
@@ -127,9 +129,11 @@ public class BaseStudentAssessmentInspectionController {
 //    @PostMapping("/export-query")
 //    @ApiOperation(value = "入参导出")
 //    public ResponseEntity<byte[]>  exportDataQuery(@Valid @RequestBody QuantitativeAssessmentExcelDto dto) {
-    @GetMapping("/export")
+    @PostMapping("/export-query")
     @ApiOperation(value = "导出")
-    public ResponseEntity<byte[]>  exportDataQuery() {
-        return inspectionService.getQuantitativeAssessmentExcelByte(new QuantitativeAssessmentExcelDto());
+    public ResponseEntity<byte[]>  exportDataQuery(@Valid CalssQuantitativeAssessmentPageDto dto) throws IOException {
+        byte[] bytes = inspectionService.getExcelByte(dto);
+        String fileName = "recordExport" + ExcelTypeEnum.XLSX.getValue();
+        return RT.fileStream(bytes, fileName);
     }
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseStudentAssessmentInspectionService.java

@@ -15,6 +15,8 @@ import com.xjrsoft.module.student.vo.BaseStudentAssessmentInspectionVo;
 import com.xjrsoft.module.student.vo.CalssQuantitativeAssessmentPageVo;
 import org.springframework.http.ResponseEntity;
 
+import java.io.IOException;
+
 /**
 * @title: 学生班级巡查考核
 * @Author dzx
@@ -68,4 +70,6 @@ public interface IBaseStudentAssessmentInspectionService extends MPJBaseService<
      * @return
      */
     Boolean noticeTeacher(Long id);
+
+    byte[] getExcelByte(CalssQuantitativeAssessmentPageDto dto) throws IOException;
 }

+ 334 - 20
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentAssessmentInspectionServiceImpl.java

@@ -22,6 +22,7 @@ import com.xjrsoft.common.enums.ScoreTypeEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.common.utils.excel.ExcelMergeUtil;
+import com.xjrsoft.module.attendance.entity.AttendanceStatistics;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
 import com.xjrsoft.module.evaluate.dto.TeaEvaluateClassDto;
@@ -64,6 +65,16 @@ import com.xjrsoft.module.system.service.IFileService;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import lombok.AllArgsConstructor;
 import me.zhyd.oauth.log.Log;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
@@ -73,11 +84,13 @@ import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -264,8 +277,7 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                         .eq(dto.getGradeId() != null, BaseClass::getGradeId, dto.getGradeId())
                         .eq(dto.getClassId() != null, BaseClass::getId, dto.getClassId())
                         .eq(dto.getClassStatus() != null, BaseClass::getIsGraduate, dto.getClassStatus())
-                        .like(dto.getName() != null && !dto.getName().equals(""), XjrUser::getName, dto.getName())
-                        .disableSubLogicDel();
+                        .like(dto.getName() != null && !dto.getName().equals(""), XjrUser::getName, dto.getName());
 
                 List<CalssQuantitativeAssessmentPageVo> resultList = baseClassMapper.selectJoinList(CalssQuantitativeAssessmentPageVo.class, baseClassMPJLambdaWrapper);
 
@@ -329,7 +341,15 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
 
                     //将结果写进对应的班级里
                     for(CalssQuantitativeAssessmentPageVo c: resultList){
+                        if(c.getOa() == null){
+                            c.setOa(" ");
+                        }
+                        if(c.getHeadTeacherName() == null){
+                            c.setHeadTeacherName(" ");
+                        }
                         Long classId = Long.parseLong(c.getClassId());
+                        c.setStuPersonalBehaviorSubScore(" ");
+                        c.setStuPersonalBehaviorScore(" ");
                         if(individualBehaviorMap.get(classId) != null){
                             Double sumScore = individualBehaviorMap.get(classId).getSumScore();
                             if(sumScore != null){
@@ -339,6 +359,8 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                             }
                         }
 
+                        c.setClassConventionalManageSubScore(" ");
+                        c.setClassConventionalManageScore(" ");
                         if(conventionalManagementMap.get(classId) != null){
                             Double sumScore = conventionalManagementMap.get(classId).getSumScore();
                             if(sumScore != null){
@@ -348,10 +370,12 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                             }
                         }
 
+                        c.setHonorSumScore(" ");
+                        c.setHonorScore(" ");
                         if(awardsAndHonorableMap.get(classId) != null){
-                            c.setHonorSumScore(awardsAndHonorableMap.get(classId).getSumScore()==null?"":awardsAndHonorableMap.get(classId).getSumScore().toString());
                             Double sumScore = awardsAndHonorableMap.get(classId).getSumScore();
                             if(sumScore != null){
+                                c.setHonorSumScore(sumScore.toString());
                                 if(sumScore < 10){
                                     c.setHonorScore(sumScore.toString());
                                 }else {
@@ -369,6 +393,8 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                             }
                         }
 
+                        c.setTeacherAssessComprehensiveIndex(" ");
+                        c.setTeacherAssessScore(" ");
                         if(classEvaluateMap.containsKey(classId)){
                             Map<Long, List<TeaEvaluateClassListVo>> evaluateCategoryMap = classEvaluateMap.get(classId).stream().collect(Collectors.groupingBy(TeaEvaluateClassListVo::getId));
                             int size = evaluateCategoryMap.size();
@@ -390,19 +416,24 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                             ScriptEngine engine = manager.getEngineByName("JavaScript");
                             try {
                                 double result = ((Number) engine.eval(replacedExpression)).doubleValue();
-                                c.setTeacherAssessScore(result + "");
+                                c.setTeacherAssessScore(result + " ");
                             } catch (ScriptException e) {
                                 Log.error(e.getMessage(), e);
                             }
                         }
+
+                        c.setMilitaryManageScore(" ");
+                        c.setMilitaryManageComprehensiveIndex(" ");
+                        c.setAssessMoney(" ");
+                        c.setAssessSumScore(" ");
                     }
                 }
                 //sheet名
                 String sheetName = "量化考核总表";
 
-//                WriteSheet writeSheet = EasyExcel.writerSheet(0, sheetName ).build();
+                WriteSheet writeSheet = EasyExcel.writerSheet(0, sheetName ).build();
 //
-//                excelWriter.write(resultList, writeSheet);
+                excelWriter.write(resultList, writeSheet);
             }
             /*for (BaseStudentAssessmentCategory bsac : baseStudentAssessmentCategorieList) {
                 dto.setBaseStudentAssessmentCategoryId(bsac.getId());
@@ -444,8 +475,7 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                 .eq(dto.getGradeId() != null, BaseClass::getGradeId, dto.getGradeId())
                 .eq(dto.getClassId() != null, BaseClass::getId, dto.getClassId())
                 .eq(dto.getClassStatus() != null, BaseClass::getIsGraduate, dto.getClassStatus())
-                .like(dto.getName() != null && !dto.getName().equals(""), XjrUser::getName, dto.getName())
-                .disableSubLogicDel();
+                .like(dto.getName() != null && !dto.getName().equals(""), XjrUser::getName, dto.getName());
 
         IPage<CalssQuantitativeAssessmentPageVo> resultPage = baseClassMapper.selectJoinPage(page, CalssQuantitativeAssessmentPageVo.class, baseClassMPJLambdaWrapper);
 
@@ -515,26 +545,28 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
 
                 if(conventionalManagementMap.get(classId) != null){
                     Double sumScore = conventionalManagementMap.get(classId).getSumScore();
-                    if(sumScore == null){
-                        sumScore = 0D;
-                    }
-                    String scoreStr = sumScore.toString();
+                    if(sumScore != null){
+                        String scoreStr = sumScore.toString();
 //                    boolean isInteger = sumScore == Math.floor(sumScore);
 //                    if(isInteger){
 //                        scoreStr = sumScore.intValue() + "";
 //                    }
-                    c.setClassConventionalManageSubScore(scoreStr);
+                        c.setClassConventionalManageSubScore(scoreStr);
 
-                    double v = (100 + sumScore) / 100 * 25;
-                    c.setClassConventionalManageScore(v + "");
+                        double v = (100 + sumScore) / 100 * 25;
+                        c.setClassConventionalManageScore(v + "");
+                    }
                 }
 
                 if(awardsAndHonorableMap.get(classId) != null){
-                    c.setHonorSumScore(awardsAndHonorableMap.get(classId).getSumScore() ==null?"":awardsAndHonorableMap.get(classId).getSumScore().toString());
-                    if(awardsAndHonorableMap.get(classId).getSumScore() < 10){
-                        c.setHonorScore(awardsAndHonorableMap.get(classId).getSumScore() ==null?"":awardsAndHonorableMap.get(classId).getSumScore().toString());
-                    }else {
-                        c.setHonorScore("10");
+                    Double sumScore = awardsAndHonorableMap.get(classId).getSumScore();
+                    if(sumScore != null){
+                        c.setHonorSumScore(sumScore.toString());
+                        if(sumScore < 10){
+                            c.setHonorScore(sumScore.toString());
+                        }else {
+                            c.setHonorScore("10");
+                        }
                     }
                 }
 
@@ -719,4 +751,286 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
         weChatService.sendTemplateMessage(weChatSendMessageDto);
         return true;
     }
+
+    @Override
+    public byte[] getExcelByte(CalssQuantitativeAssessmentPageDto dto) throws IOException {
+        IPage<CalssQuantitativeAssessmentPageVo> page = this.getCalssQuantitativeAssessmentPage(new Page<>(1, 10000), dto);
+
+        Workbook workbook = new XSSFWorkbook();
+        // 创建一个工作表(sheet)
+        String sheetName = "数据";
+        Sheet sheet = workbook.createSheet(sheetName);
+        createFirstTitle(workbook, sheet);
+        createSecondTitle(workbook, sheet, 6);
+
+        Font font = workbook.createFont();
+        font.setBold(false);// 设置为粗体
+        font.setFontName("宋体");
+        CellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font); // 将字体应用到样式
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+
+        int sortCode = 1;
+        for (CalssQuantitativeAssessmentPageVo pageVo : page.getRecords()) {
+            Row dataRow = sheet.createRow(sortCode + 1);
+
+            int columnNumber = 0;
+            Cell cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(sortCode + "");
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getOa());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getClassName());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getHeadTeacherName());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getStudentNum().toString());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getClassStatusCn());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getStuPersonalBehaviorSubScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getStuPersonalBehaviorScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getClassConventionalManageSubScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getClassConventionalManageScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getHonorSumScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getHonorScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getMilitaryManageComprehensiveIndex());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getMilitaryManageScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getTeacherAssessComprehensiveIndex());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getTeacherAssessScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getAssessSumScore());
+            cell.setCellStyle(cellStyle);
+
+            columnNumber ++;
+            cell = dataRow.createCell(columnNumber);
+            cell.setCellValue(pageVo.getAssessMoney());
+            cell.setCellStyle(cellStyle);
+
+            sortCode ++;
+        }
+
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        workbook.write(bot);
+        return bot.toByteArray();
+    }
+
+    void createFirstTitle(Workbook workbook, Sheet sheet) {
+        int rowNumber = 0;
+        Font font = workbook.createFont();
+        font.setFontName("宋体");
+        //font.setColor(IndexedColors.RED.getIndex()); // 设置字体颜色为红色
+        font.setFontHeightInPoints((short)12);
+
+        CellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font); // 将字体应用到样式
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+
+        Row row = sheet.createRow(rowNumber);
+        //3、处理表头
+        int columnNumber = 0;
+        Cell cell = row.createCell(columnNumber);
+        cell.setCellValue("序号");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("工号");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("班级");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("班主任");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("人数");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("状态");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("学生个人行为");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, columnNumber, columnNumber + 1));
+        columnNumber ++;
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("常规管理");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, columnNumber, columnNumber + 1));
+        columnNumber ++;
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("获奖及荣誉奖章");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, columnNumber, columnNumber + 1));
+        columnNumber ++;
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("准军事化管理效果");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, columnNumber, columnNumber + 1));
+        columnNumber ++;
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("任课教师考核");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, columnNumber, columnNumber + 1));
+        columnNumber ++;
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("月份总得分");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+
+        columnNumber ++;
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("月考核金额");
+        cell.setCellStyle(cellStyle);
+        sheet.addMergedRegion(new CellRangeAddress(0, 1, columnNumber, columnNumber));
+    }
+
+    void createSecondTitle(Workbook workbook, Sheet sheet, int startColunm) {
+        int rowNumber = 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);
+
+        Row row = sheet.createRow(rowNumber);
+
+        int columnNumber = startColunm;
+        Cell cell = row.createCell(columnNumber);
+        cell.setCellValue("扣分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("此项得分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("扣分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("此项得分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("扣分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("此项得分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("扣分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("此项得分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("扣分");
+        cell.setCellStyle(cellStyle);
+        columnNumber ++;
+
+        cell = row.createCell(columnNumber);
+        cell.setCellValue("此项得分");
+        cell.setCellStyle(cellStyle);
+    }
 }