Parcourir la source

12.31,推送邮件附件excel和工作间问题

Crazy il y a 2 mois
Parent
commit
a7eeab3772
10 fichiers modifiés avec 348 ajouts et 203 suppressions
  1. 1 1
      yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java
  2. 8 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java
  3. 273 155
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java
  4. 59 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/StudentAttendanceCollegeTemplateVO.java
  5. 6 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/StudentAttendanceSupervisorTemplateVO.java
  6. 1 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentAttendance/vo/StudentAttendancePageReqVO.java
  7. 0 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectionProject/vo/studentSelectionProjectRespVO.java
  8. 0 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectionProject/vo/studentSelectionProjectSaveReqVO.java
  9. 0 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
  10. 0 28
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/studentSelectionProject/studentSelectionProjectDO.java

+ 1 - 1
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java

@@ -205,7 +205,7 @@ public class MpMessageServiceImpl implements MpMessageService {
         LocalDate localDate = LocalDate.now();
         StudentAttendancePageReqVO pageReqVO =new StudentAttendancePageReqVO();
         pageReqVO.setDate(localDate);
-        pageReqVO.setDeptId(String.valueOf(deptId));
+        pageReqVO.setDeptId(deptId);
         List<StudentAttendanceDO> attendanceList= studentAttendanceService.getStudentAttendancePage(pageReqVO).getList();
 
         //仅导师工作间下的

+ 8 - 5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java

@@ -82,8 +82,9 @@ public class DeptController {
         List<Long> originLeaderList = originNewDept.getLeaderUserId();
         List<Long> newLeaderList =  updateReqVO.getLeaderUserId();
 
+        // 新的负责人为空时,直接清空教师的工作间id
         if(newLeaderList == null || newLeaderList.isEmpty()){
-            List<AdminUserDO> teachers = adminUserService.getUserList(newLeaderList);
+            List<AdminUserDO> teachers = adminUserService.getUserList(originLeaderList);
             if (teachers!=null&&!teachers.isEmpty()) {
                 for (AdminUserDO teacher : teachers) {//负责人的工作间
                     teacher.setDeptId(0L);
@@ -92,20 +93,22 @@ public class DeptController {
             }
             return success(true);
         }
-        // 新的负责人为空时,直接清空 ,如果不为空,则与原先有三种情况,增、减、同
+
+        // 如果不为空,则与原先有三种情况,增、减、同
         if (originLeaderList != null ){
+            //减
             for (Long teacherId : originLeaderList) {//负责人的工作间
-                if(!newLeaderList.contains(teacherId)){
-                    //给教师删除所有的dept
+                if(!newLeaderList.contains(teacherId)){//新的不包含教师id
+                    //给教师删除deptId
                     AdminUserDO teacher = adminUserService.getUser(teacherId);
                     if (teacher!=null) {
-                        //TODO设置成测绘学院(默认)
                         teacher.setDeptId(0L);
                         adminUserService.updateUser(BeanUtils.toBean(teacher, UserSaveReqVO.class));
                     }
                 }
                 newLeaderList.remove(teacherId);
             }
+            //增
             List<AdminUserDO> teachers = adminUserService.getUserList(newLeaderList);
             if (teachers!=null&&!teachers.isEmpty()) {
                 for (AdminUserDO teacher : teachers) {//负责人的工作间

+ 273 - 155
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/MailTemplateController.java

@@ -3,16 +3,11 @@ package cn.iocoder.yudao.module.system.controller.admin.mail;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 import cn.iocoder.yudao.module.system.controller.admin.mail.vo.template.*;
 import cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo.StudentAttendanceEmailVO;
 import cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo.StudentAttendancePageReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo.StudentAttendanceRespVO;
 import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.graduateStudentExportExcelVO;
-import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
-import cn.iocoder.yudao.module.system.dal.dataobject.studentAttendance.StudentAttendanceDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import cn.iocoder.yudao.module.system.service.mail.MailSendService;
@@ -26,6 +21,7 @@ import com.alibaba.excel.write.metadata.WriteSheet;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -35,8 +31,8 @@ import javax.validation.Valid;
 import java.io.*;
 import java.time.DayOfWeek;
 import java.time.LocalDate;
-import java.time.temporal.TemporalAdjusters;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@@ -59,82 +55,26 @@ public class MailTemplateController {
     @Resource
     private PermissionService permissionService;
 
-    @Scheduled(cron = "0 30 8 * * ?") // 每天晚上 22:30
+    private static final short[] COLUMN_WIDTHS = {20, 20, 20, 20}; // 根据需要设置列宽
+
+    @Scheduled(cron = "0 30 8 * * ?") // 每天早上 8:30发送前一天的
     @Operation(summary = "定时发送邮件给导师")
     public void sendMailToTeacherScheduled() {
-        // 创建结果对象并设置属性
-        UserPageReqVO reqVO = new UserPageReqVO();
-        reqVO.setUserType("3");//找导师
-        List<AdminUserDO> TeacherList = adminUserService.getUserList(reqVO);
-        StudentAttendancePageReqVO pageReqVO =new StudentAttendancePageReqVO();
-        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
-        // 获取前一天
-        LocalDate yesterday = LocalDate.now().minusDays(1);
-        // 检查昨天是否是周日
-        if (yesterday.getDayOfWeek() == DayOfWeek.MONDAY) {
-            return; // 直接返回,不推送周日的
-        }
-
-        if ( TeacherList!=null&& !TeacherList.isEmpty()) {
-            for (AdminUserDO teacher : TeacherList) {
-                pageReqVO.setDate(yesterday);
-                List<StudentAttendanceEmailVO> normalList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
-                        StudentAttendanceEmailVO.class
-                );
-                List<StudentAttendanceEmailVO> errorList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
-                        StudentAttendanceEmailVO.class
-                );
-                List<StudentAttendanceEmailVO> excusedList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
-                        StudentAttendanceEmailVO.class
-                );
-
-                StringBuilder normalListBuilder = new StringBuilder();
-                for (StudentAttendanceEmailVO attendance : normalList) {
-                    normalListBuilder
-                            .append(", 学生姓名: ").append(attendance.getStudentName())
-                            .append(", 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
-                            .append(", 日期: ").append(attendance.getDate())
-                            .append(", 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "未打卡")
-                            .append("<br/>");
-                }
-
-                StringBuilder errorListBuilder = new StringBuilder();
-                for (StudentAttendanceEmailVO attendance : errorList) {
-                    errorListBuilder
-                            .append(", 学生姓名: ").append(attendance.getStudentName())
-                            .append(", 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
-                            .append(", 日期: ").append(attendance.getDate())
-                            .append(", 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "未打卡")
-                            .append("<br/>");
-                }
-
-                StringBuilder excusedListBuilder = new StringBuilder();
-                for (StudentAttendanceEmailVO attendance : excusedList) {
-                    excusedListBuilder
-                            .append(", 学生姓名: ").append(attendance.getStudentName())
-                            .append(", 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
-                            .append(", 日期: ").append(attendance.getDate())
-                            .append(", 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "请假")
-                            .append("<br/>");
-                }
-
-                templateParams.put("normalList", normalListBuilder.toString());
-                templateParams.put("errorList", errorListBuilder.toString());
-                templateParams.put("excusedList", excusedListBuilder.toString());
-                if (teacher.getEmail() != null) {
-                    mailSendService.sendSingleMailToMember(teacher.getEmail(), null, "attendance-list", templateParams);
-                }
-            }
+        try {
+            sendExcelMailToTeacher();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
         }
     }
 
-    @Scheduled(cron = "0 30 8 * * ?") // 每天晚上 22:30
+    @Scheduled(cron = "0 30 8 * * ?") // 每天早上 8:30发送前一天的
     @Operation(summary = "定时发送邮件给学院")
     public void sendMailToCollegeScheduled() {
-        testCollege();
+        try {
+            sendExcelMailToCollege();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     @PostMapping("/create")
@@ -193,15 +133,151 @@ public class MailTemplateController {
                 sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams()));
     }
 
+    @PostMapping("/sendExcelToTeacher")
+    @Operation(summary = "发送Excel给导师")
+    public void sendExcelMailToTeacher() throws IOException {
+        // 获取导师
+        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+        List<AdminUserDO> TeacherList = adminUserService.getUserList(collegeIdList);
+
+        StudentAttendancePageReqVO pageReqVO = new StudentAttendancePageReqVO();
+        Map<String, Object> templateParams = new HashMap<>(); // 模板参数设置
+
+        // 获取前一天
+        LocalDate yesterday = LocalDate.now().minusDays(1);
+        //        // 检查昨天是否是周日
+//        if (yesterday.getDayOfWeek() == DayOfWeek.SUNDAY) {
+//            return; // 直接返回,不推送周日的
+//        }
+        if (TeacherList != null && !TeacherList.isEmpty()) {
+            for (AdminUserDO teacher : TeacherList) {
+                if (teacher.getDeptId() == null || teacher.getDeptId() == 0) {
+                    return;
+                }
+                pageReqVO.setDate(yesterday);
+                pageReqVO.setDeptId(teacher.getDeptId());
+                List<StudentAttendanceSupervisorTemplateVO> normalList = BeanUtils.toBean(
+                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO),
+                        StudentAttendanceSupervisorTemplateVO.class
+                );
+                List<StudentAttendanceSupervisorTemplateVO> errorList = BeanUtils.toBean(
+                        studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO),
+                        StudentAttendanceSupervisorTemplateVO.class
+                );
+                List<StudentAttendanceSupervisorTemplateVO> excusedList = BeanUtils.toBean(
+                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO),
+                        StudentAttendanceSupervisorTemplateVO.class
+                );
+                // 创建 ByteArrayOutputStream 用来存储 Excel 文件数据
+                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+                // 写入 Excel 文件
+                try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceSupervisorTemplateVO.class).build()) {
+                    WriteSheet writeSheetNormal = EasyExcel.writerSheet("正常打卡信息").build();
+                    WriteSheet writeSheetError = EasyExcel.writerSheet("未打卡信息").build();
+                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
+
+                    // 将各个 List 数据写入不同的 Sheet 中
+                    excelWriter.write(normalList, writeSheetNormal);
+                    excelWriter.write(errorList, writeSheetError);
+                    excelWriter.write(excusedList, writeSheetExcused);
+                }
+
+                // 创建附件 Map
+                Map<String, InputStream> attachments = new HashMap<>();
+                // 使用 ByteArrayInputStream 来创建附件
+                attachments.put(yesterday+"_"+teacher.getDeptName()+"考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
+
+                // 发送邮件,包含附件
+                if (teacher.getEmail() != null) {
+                    mailSendService.sendSingleMailToMemberWithAttachments(teacher.getEmail(), null, "attendance-list-excel", templateParams, attachments);
+                }
+            }
+        }
+    }
+
+    @PostMapping("/sendExcelToCollege")
+    @Operation(summary = "发送Excel给学院")
+    public void sendExcelMailToCollege() throws IOException {
+        UserPageReqVO reqVO = new UserPageReqVO();
+        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+
+        Set<AdminUserDO> collegeList  = new HashSet<>();
+        List<AdminUserDO> collegeList1 = adminUserService.getUserList(collegeIdList);
+        reqVO.setUserType("4");
+        List<AdminUserDO> collegeList2 = adminUserService.getUserList(reqVO);
+
+        collegeList.addAll(collegeList1);
+        collegeList.addAll(collegeList2);
+
+        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+
+        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
+
+        // 获取前一天
+        LocalDate yesterday = LocalDate.now().minusDays(1);
+        if ( !collegeList.isEmpty()) {
+            for (AdminUserDO college : collegeList) {
+
+                attendanceReqVO.setDate(yesterday);
+                List<StudentAttendanceCollegeTemplateVO> normalList = BeanUtils.toBean(
+                        studentAttendanceService.getStudentAttendanceListForTeacher(attendanceReqVO),
+                        StudentAttendanceCollegeTemplateVO.class
+                );
+                List<StudentAttendanceCollegeTemplateVO> errorList = studentAttendanceService.getStudentAttendanceErrorListForTeacher(attendanceReqVO)
+                        .stream()
+                        .map(studentAttendance -> {
+                            StudentAttendanceCollegeTemplateVO vo = BeanUtils.toBean(studentAttendance, StudentAttendanceCollegeTemplateVO.class);
+                            vo.setClockInTime("未打卡");
+                            return vo;
+                        })
+                        .collect(Collectors.toList());
+
+                List<StudentAttendanceCollegeTemplateVO> excusedList = studentAttendanceService.getStudentAttendanceExcusedListForTeacher(attendanceReqVO)
+                        .stream()
+                        .map(studentAttendance -> {
+                            StudentAttendanceCollegeTemplateVO vo = BeanUtils.toBean(studentAttendance, StudentAttendanceCollegeTemplateVO.class);
+                            vo.setClockInTime("请假");
+                            return vo;
+                        })
+                        .collect(Collectors.toList());
+
+                // 输出 Excel
+                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+                // 写入 Excel 文件
+                try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceCollegeTemplateVO.class).build()) {
+                    WriteSheet writeSheetNormal = EasyExcel.writerSheet("正常打卡信息").build();
+                    WriteSheet writeSheetError = EasyExcel.writerSheet("未打卡信息").build();
+                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
+
+                    excelWriter.write(normalList, writeSheetNormal);
+                    excelWriter.write(errorList, writeSheetError);
+                    excelWriter.write(excusedList, writeSheetExcused);
+                }
+
+                // 附件
+                Map<String, InputStream> attachments = new HashMap<>();
+                // 创建附件
+                attachments.put(yesterday+"_"+"考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
+
+                // 发送邮件,包含附件
+                if (college.getEmail() != null) {
+                    mailSendService.sendSingleMailToMemberWithAttachments(college.getEmail(), null, "attendance-list-excel", templateParams, attachments);
+                }
+            }
+        }
+    }
+
 
     @PostMapping("/testTeacher")
-    @Operation(summary = "定时发送邮件给导师")
+    @Operation(summary = "测试发送邮件给导师")
     public void testTeacher() {
-        // 创建结果对象并设置属性
-        UserPageReqVO reqVO = new UserPageReqVO();
+        // 获取导师
+        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+        List<AdminUserDO> TeacherList = adminUserService.getUserList(collegeIdList);
+
 
-        reqVO.setUserType("3");//找导师
-        List<AdminUserDO> TeacherList = adminUserService.getUserList(reqVO);
         StudentAttendancePageReqVO pageReqVO =new StudentAttendancePageReqVO();
         Map<String, Object> templateParams =new HashMap<>();//模板参数设置
 
@@ -214,17 +290,21 @@ public class MailTemplateController {
 
         if ( TeacherList!=null&& !TeacherList.isEmpty()) {
             for (AdminUserDO teacher : TeacherList) {
+                if (teacher.getDeptId() == null || teacher.getDeptId() == 0) {
+                    return;
+                }
                 pageReqVO.setDate(yesterday);
+                pageReqVO.setDeptId(teacher.getDeptId());
                 List<StudentAttendanceEmailVO> normalList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
+                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO),
                         StudentAttendanceEmailVO.class
                 );
                 List<StudentAttendanceEmailVO> errorList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
+                        studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO),
                         StudentAttendanceEmailVO.class
                 );
                 List<StudentAttendanceEmailVO> excusedList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
+                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO),
                         StudentAttendanceEmailVO.class
                 );
 
@@ -270,7 +350,7 @@ public class MailTemplateController {
     }
 
     @PostMapping("/testCollege")
-    @Operation(summary = "定时发送邮件给学院")
+    @Operation(summary = "测试发送邮件给学院")
     public void testCollege() {
         UserPageReqVO reqVO = new UserPageReqVO();
         Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
@@ -298,6 +378,7 @@ public class MailTemplateController {
 
         if ( !collegeList.isEmpty()) {
             for (AdminUserDO college : collegeList) {
+
                 attendanceReqVO.setDate(yesterday);
                 List<StudentAttendanceEmailVO> normalList = BeanUtils.toBean(
                         studentAttendanceService.getStudentAttendanceListForTeacher(attendanceReqVO),
@@ -358,109 +439,146 @@ public class MailTemplateController {
         }
     }
 
-    @PostMapping("/SendExcelToTeacher")
-    @Operation(summary = "发送Excel给导师")
-    public void sendExcelMailToTeacherScheduled() throws IOException {
-        // 创建结果对象并设置属性
-        UserPageReqVO reqVO = new UserPageReqVO();
-        reqVO.setUserType("3"); // 找导师
-        List<AdminUserDO> TeacherList = adminUserService.getUserList(reqVO);
+    @PostMapping("/ceshiSendExcelToTeacher")
+    @Operation(summary = "测试发送Excel给老师")
+    public void ceshiSendExcelMail(@RequestParam("email") String email) throws IOException {
+
+        // 获取导师
+        Set<Long> collegeIdList = permissionService.getUserListByRoleId(114L);
+        List<AdminUserDO> TeacherList = adminUserService.getUserList(collegeIdList);
+
         StudentAttendancePageReqVO pageReqVO = new StudentAttendancePageReqVO();
         Map<String, Object> templateParams = new HashMap<>(); // 模板参数设置
 
-        LocalDate today = LocalDate.now();
+        LocalDate yesterday = LocalDate.now().minusDays(1);
         if (TeacherList != null && !TeacherList.isEmpty()) {
             for (AdminUserDO teacher : TeacherList) {
-                pageReqVO.setDate(today);
-                List<StudentAttendanceTemplateVO> normalList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO.setDeptId(String.valueOf(0))),
-                        StudentAttendanceTemplateVO.class
-                );
-                List<StudentAttendanceTemplateVO> errorList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO.setDeptId(String.valueOf(0))),
-                        StudentAttendanceTemplateVO.class
-                );
-                List<StudentAttendanceTemplateVO> excusedList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setDeptId(String.valueOf(0))),
-                        StudentAttendanceTemplateVO.class
+
+                pageReqVO.setDate(yesterday);
+                pageReqVO.setDeptId(teacher.getDeptId());
+
+                List<StudentAttendanceSupervisorTemplateVO> normalList = BeanUtils.toBean(
+                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO),
+                        StudentAttendanceSupervisorTemplateVO.class
                 );
-                // 输出 Excel
-                ByteArrayOutputStream normalOutputStream = new ByteArrayOutputStream();
-                ByteArrayOutputStream errorOutputStream = new ByteArrayOutputStream();
-                ByteArrayOutputStream excusedOutputStream = new ByteArrayOutputStream();
-
-                EasyExcel.write(normalOutputStream, StudentAttendanceTemplateVO.class).sheet("正常打卡信息").doWrite(normalList);
-                normalOutputStream.close();
-                EasyExcel.write(errorOutputStream, StudentAttendanceTemplateVO.class).sheet("未打卡信息").doWrite(errorList);
-                errorOutputStream.close();
-                EasyExcel.write(excusedOutputStream, StudentAttendanceTemplateVO.class).sheet("请假信息").doWrite(excusedList);
-                errorOutputStream.close();
-
-                // 构造附件Map
+
+                List<StudentAttendanceSupervisorTemplateVO> errorList = studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO)
+                        .stream()
+                        .map(studentAttendance -> {
+                            StudentAttendanceSupervisorTemplateVO vo = BeanUtils.toBean(studentAttendance, StudentAttendanceSupervisorTemplateVO.class);
+                            vo.setClockInTime("未打卡");
+                            return vo;
+                        })
+                        .collect(Collectors.toList());
+
+                List<StudentAttendanceSupervisorTemplateVO> excusedList = studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO)
+                        .stream()
+                        .map(studentAttendance -> {
+                            StudentAttendanceSupervisorTemplateVO vo = BeanUtils.toBean(studentAttendance, StudentAttendanceSupervisorTemplateVO.class);
+                            vo.setClockInTime("请假");
+                            return vo;
+                        })
+                        .collect(Collectors.toList());
+
+                // 创建 ByteArrayOutputStream 用来存储 Excel 文件数据
+                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+                // 写入 Excel 文件
+                try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceSupervisorTemplateVO.class).build()) {
+
+                    WriteSheet writeSheetNormal =EasyExcel.writerSheet("正常打卡信息").build();
+                    WriteSheet writeSheetError =EasyExcel.writerSheet("未打卡信息").build();
+                    WriteSheet writeSheetExcused =EasyExcel.writerSheet("请假信息").build();
+
+                    excelWriter.write(normalList, writeSheetNormal);
+                    excelWriter.write(errorList, writeSheetError);
+                    excelWriter.write(excusedList, writeSheetExcused);
+                }
+
+                // 创建附件 Map
                 Map<String, InputStream> attachments = new HashMap<>();
-                attachments.put("正常考勤信息.xlsx", new ByteArrayInputStream(normalOutputStream.toByteArray()));
-                attachments.put("未打卡信息.xlsx", new ByteArrayInputStream(normalOutputStream.toByteArray()));
-                attachments.put("请假.xlsx", new ByteArrayInputStream(normalOutputStream.toByteArray()));
 
-                // 发送邮件,包含附件
+                attachments.put(yesterday+"_"+teacher.getDeptName()+"考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
+
+                // 发送邮件
                 if (teacher.getEmail() != null) {
-                    mailSendService.sendSingleMailToMemberWithAttachments(teacher.getEmail(), null, "attendance-list-excel", templateParams, attachments);
+                    mailSendService.sendSingleMailToMemberWithAttachments(email, null, "attendance-list-excel", templateParams, attachments);
                 }
             }
         }
     }
 
-    @PostMapping("/CeshiSendExcel")
-    @Operation(summary = "测试发送Excel")
-    public void CeshiSendExcelMail() throws IOException {
-        // 创建结果对象并设置属性
+    @PostMapping("/ceshiExcelToCollege")
+    @Operation(summary = "测试发送Excel给学院")
+    public void ceshiExcelToCollege(@RequestParam("email") String email) throws IOException {
         UserPageReqVO reqVO = new UserPageReqVO();
-        reqVO.setUserType("3"); // 找导师
-        List<AdminUserDO> TeacherList = adminUserService.getUserList(reqVO);
-        StudentAttendancePageReqVO pageReqVO = new StudentAttendancePageReqVO();
-        Map<String, Object> templateParams = new HashMap<>(); // 模板参数设置
+        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
 
-        LocalDate today = LocalDate.now();
-        if (TeacherList != null && !TeacherList.isEmpty()) {
-            for (AdminUserDO teacher : TeacherList) {
-                pageReqVO.setDate(today);
-                List<StudentAttendanceTemplateVO> normalList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
-                        StudentAttendanceTemplateVO.class
-                );
-                List<StudentAttendanceTemplateVO> errorList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
-                        StudentAttendanceTemplateVO.class
-                );
-                List<StudentAttendanceTemplateVO> excusedList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setDeptId(String.valueOf(teacher.getDeptId()))),
-                        StudentAttendanceTemplateVO.class
+        Set<AdminUserDO> collegeList  = new HashSet<>();
+        List<AdminUserDO> collegeList1 = adminUserService.getUserList(collegeIdList);
+        reqVO.setUserType("4");
+        List<AdminUserDO> collegeList2 = adminUserService.getUserList(reqVO);
+
+        collegeList.addAll(collegeList1);
+        collegeList.addAll(collegeList2);
+        //找学院
+        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+
+        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
+
+        // 获取前一天
+        LocalDate yesterday = LocalDate.now().minusDays(1);
+        if ( !collegeList.isEmpty()) {
+            for (AdminUserDO college : collegeList) {
+
+                attendanceReqVO.setDate(yesterday);
+                List<StudentAttendanceCollegeTemplateVO> normalList = BeanUtils.toBean(
+                        studentAttendanceService.getStudentAttendanceListForTeacher(attendanceReqVO),
+                        StudentAttendanceCollegeTemplateVO.class
                 );
-                // 输出单个Excel文件,包含多个Sheet
-                try (ExcelWriter excelWriter = EasyExcel.write("attendance.xlsx", StudentAttendanceTemplateVO.class).build()) {
+                List<StudentAttendanceCollegeTemplateVO> errorList = studentAttendanceService.getStudentAttendanceErrorListForTeacher(attendanceReqVO)
+                        .stream()
+                        .map(studentAttendance -> {
+                            StudentAttendanceCollegeTemplateVO vo = BeanUtils.toBean(studentAttendance, StudentAttendanceCollegeTemplateVO.class);
+                            vo.setClockInTime("未打卡");
+                            return vo;
+                        })
+                        .collect(Collectors.toList());
+
+                List<StudentAttendanceCollegeTemplateVO> excusedList = studentAttendanceService.getStudentAttendanceExcusedListForTeacher(attendanceReqVO)
+                        .stream()
+                        .map(studentAttendance -> {
+                            StudentAttendanceCollegeTemplateVO vo = BeanUtils.toBean(studentAttendance, StudentAttendanceCollegeTemplateVO.class);
+                            vo.setClockInTime("请假");
+                            return vo;
+                        })
+                        .collect(Collectors.toList());
+
+                // 输出 Excel
+                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+                // 写入 Excel 文件
+                try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceCollegeTemplateVO.class).build()) {
                     WriteSheet writeSheetNormal = EasyExcel.writerSheet("正常打卡信息").build();
                     WriteSheet writeSheetError = EasyExcel.writerSheet("未打卡信息").build();
                     WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
 
+                    // 将各个 List 数据写入不同的 Sheet 中
                     excelWriter.write(normalList, writeSheetNormal);
                     excelWriter.write(errorList, writeSheetError);
                     excelWriter.write(excusedList, writeSheetExcused);
                 }
 
-                // 构造附件Map
                 Map<String, InputStream> attachments = new HashMap<>();
-                try (FileInputStream fileInputStream = new FileInputStream("attendance.xlsx")) {
-                    attachments.put("考勤信息.xlsx", fileInputStream);
-                }
+                // 使用 ByteArrayInputStream 来创建附件
+                attachments.put(yesterday+"_"+"考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
 
                 // 发送邮件,包含附件
-                if (teacher.getEmail() != null) {
-                    mailSendService.sendSingleMailToMemberWithAttachments(teacher.getEmail(), null, "attendance-list-excel", templateParams, attachments);
+                if (college.getEmail() != null) {
+                    mailSendService.sendSingleMailToMemberWithAttachments(email, null, "attendance-list-excel", templateParams, attachments);
                 }
             }
         }
     }
 
-
-
 }

+ 59 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/StudentAttendanceCollegeTemplateVO.java

@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 邮件学生考勤信息模版的Response VO")
+@Data
+public class StudentAttendanceCollegeTemplateVO {
+
+
+    @Schema(description = "学生名字")
+    @ColumnWidth(20)
+    @ExcelProperty(value = "学生名字")
+    private String studentName;
+
+    @Schema(description = "学生学号")
+    @ColumnWidth(20)
+    @ExcelProperty(value = "学生学号")
+    private String userNumber;
+
+    @Schema(description = "工作间名称")
+    @ColumnWidth(20)
+    @ExcelProperty(value = "工作间名称")
+    private String deptName;
+
+    @Schema(description = "导师名称")
+    @ColumnWidth(20)
+    @ExcelProperty(value = "导师名称")
+    private String supervisor;
+
+    @Schema(description = "日期")
+    @ColumnWidth(20)
+    @ExcelProperty(value = "日期")
+    private String date;
+
+    @Schema(description = "打卡时间")
+    @ColumnWidth(20)
+    @ExcelProperty(value = "打卡时间")
+    private String clockInTime;
+
+    public String getDeptName() {
+        return deptName == null ? "无" : deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    public String getSupervisor() {
+        return supervisor == null ? "无" : supervisor;
+    }
+
+    public void setSupervisor(String supervisor) {
+        this.supervisor = supervisor;
+    }
+
+}

+ 6 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/StudentAttendanceTemplateVO.java → yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/mail/vo/template/StudentAttendanceSupervisorTemplateVO.java

@@ -1,27 +1,32 @@
 package cn.iocoder.yudao.module.system.controller.admin.mail.vo.template;
 
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 @Schema(description = "管理后台 - 邮件学生考勤信息模版的Response VO")
 @Data
-public class StudentAttendanceTemplateVO {
+public class StudentAttendanceSupervisorTemplateVO {
 
 
     @Schema(description = "学生名字")
+    @ColumnWidth(20)
     @ExcelProperty(value = "学生名字")
     private String studentName;
 
     @Schema(description = "学生学号")
+    @ColumnWidth(20)
     @ExcelProperty(value = "学生学号")
     private String userNumber;
 
     @Schema(description = "日期")
+    @ColumnWidth(20)
     @ExcelProperty(value = "日期")
     private String date;
 
     @Schema(description = "打卡时间")
+    @ColumnWidth(20)
     @ExcelProperty(value = "打卡时间")
     private String clockInTime;
 }

+ 1 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentAttendance/vo/StudentAttendancePageReqVO.java

@@ -24,7 +24,7 @@ public class StudentAttendancePageReqVO extends PageParam {
     private String studentName;
 
     @Schema(description = "工作间id", example = "114")
-    private String deptId;
+    private Long deptId;
 
     @Schema(description = "学生学号", example = "114")
     private String userNumber;

+ 0 - 6
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectionProject/vo/studentSelectionProjectRespVO.java

@@ -38,12 +38,6 @@ public class studentSelectionProjectRespVO {
     @ExcelProperty("导师id数组")
     private List<Long> supervisorIds;
 
-    @Schema(description = "是否开启导师弹窗")
-    private Integer isSupervisor;
-
-    @Schema(description = "是否开启学生弹窗")
-    private Integer isStudent;
-
     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
     @ExcelProperty("创建时间")
     private LocalDateTime createTime;

+ 0 - 5
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/studentSelectionProject/vo/studentSelectionProjectSaveReqVO.java

@@ -34,10 +34,5 @@ public class studentSelectionProjectSaveReqVO {
 //    @NotEmpty(message = "导师不能为空")
     private List<Long> supervisorIds;
 
-    @Schema(description = "是否开启导师弹窗")
-    private Integer isSupervisor;
-
-    @Schema(description = "是否开启学生弹窗")
-    private Integer isStudent;
 
 }

+ 0 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java

@@ -136,7 +136,6 @@ public class UserController {
                 });
             }
         }
-
         return success(true);
     }
 

+ 0 - 28
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/studentSelectionProject/studentSelectionProjectDO.java

@@ -51,33 +51,5 @@ public class studentSelectionProjectDO extends BaseDO {
      */
     private String supervisorIds;
 
-    /**
-     * 是否开启导师弹窗
-     */
-    private Integer isSupervisor;
-
-    /**
-     * 是否开启学生弹窗
-     */
-    private Integer isStudent;
 
-//    public List<Long> getSupervisorIds() {
-//        if (supervisorIds == null || supervisorIds.isEmpty()) {
-//            return new ArrayList<>();
-//        }
-//
-//        // 清洗掉 [ 和 ] 字符
-//        String cleanedIds = supervisorIds.replaceAll("[\\[\\]]", "").trim();
-//        // 使用逗号分割数字字符串
-//        String[] idsArray = cleanedIds.split(",");
-//        List<Long> idsList = new ArrayList<>();
-//        for (String id : idsArray) {
-//            try {
-//                idsList.add(Long.parseLong(id.trim())); // 转换为 Long 类型并加入列表
-//            } catch (NumberFormatException e) {
-//                System.err.println("无法转换为 Long 类型: " + id);
-//            }
-//        }
-//        return idsList;
-//    }
 }