Jelajahi Sumber

定时重启设备

ydmyzx 3 hari lalu
induk
melakukan
7e62e36b7d

+ 3 - 3
yudao-module-md/yudao-module-md-biz/src/main/java/Acs/EventSearch.java

@@ -105,7 +105,7 @@ public final class EventSearch {
 //                System.out.println("NET_DVR_GetNextRemoteConfig接口调用失败,错误码:" + AcsService.hCNetSDK.NET_DVR_GetLastError());
 //            }
             if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_NEED_WAIT) {
-                System.out.println("配置等待....");
+//                System.out.println("配置等待....");
                 try {
                     Thread.sleep(10);
                 } catch (InterruptedException e) {
@@ -113,10 +113,10 @@ public final class EventSearch {
                 }
                 continue;
             } else if (dwEventSearch == HCNetSDK.NET_SDK_NEXT_STATUS__FINISH) {
-                System.out.println("获取事件完成");
+//                System.out.println("获取事件完成");
                 break;
             } else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_FAILED) {
-                System.out.println("获取事件出现异常");
+//                System.out.println("获取事件出现异常");
                 break;
             } else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS) {
                 StudentAttendanceDO attendance =new StudentAttendanceDO();

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

@@ -85,14 +85,14 @@ public class MailTemplateController {
     @PostMapping("/create")
     @Operation(summary = "创建邮件模版")
     @PreAuthorize("@ss.hasPermission('system:mail-template:create')")
-    public CommonResult<Long> createMailTemplate(@Valid @RequestBody MailTemplateSaveReqVO createReqVO){
+    public CommonResult<Long> createMailTemplate(@Valid @RequestBody MailTemplateSaveReqVO createReqVO) {
         return success(mailTempleService.createMailTemplate(createReqVO));
     }
 
     @PutMapping("/update")
     @Operation(summary = "修改邮件模版")
     @PreAuthorize("@ss.hasPermission('system:mail-template:update')")
-    public CommonResult<Boolean> updateMailTemplate(@Valid @RequestBody MailTemplateSaveReqVO updateReqVO){
+    public CommonResult<Boolean> updateMailTemplate(@Valid @RequestBody MailTemplateSaveReqVO updateReqVO) {
         mailTempleService.updateMailTemplate(updateReqVO);
         return success(true);
     }
@@ -142,7 +142,7 @@ public class MailTemplateController {
     @Operation(summary = "发送Word给导师")
     public void sendWordMailToTeacher() throws IOException {
         // 获取导师
-        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(113L);
+        Set<Long> collegeIdList = permissionService.getUserListByRoleId(113L);
         List<AdminUserDO> TeacherList = adminUserService.getUserList(collegeIdList);
 
         StudentAttendancePageReqVO pageReqVO = new StudentAttendancePageReqVO();
@@ -150,6 +150,7 @@ public class MailTemplateController {
 
         // 获取前一天
         LocalDate yesterday = LocalDate.now().minusDays(1);
+//        LocalDate yesterday = LocalDate.now();
 
         if (TeacherList != null && !TeacherList.isEmpty()) {
             for (AdminUserDO teacher : TeacherList) {
@@ -165,47 +166,85 @@ public class MailTemplateController {
                         studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO.setSupervisorId(teacher.getId())),
                         StudentAttendanceSupervisorTemplateVO.class
                 );
-//                List<StudentAttendanceSupervisorTemplateVO> excusedList = BeanUtils.toBean(
-//                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setSupervisorId(getLoginUserId())),
-//                        StudentAttendanceSupervisorTemplateVO.class
-//                );
+                if (normalList.isEmpty() && errorList.isEmpty()) {
+                    if(!adminUserService.isSupervisorNullHasStudent(teacher.getId())){
+                        continue;
+                    }
+                }
+                // 创建 ByteArrayOutputStream 用来存储 Word 文件数据
+                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 
+                templateParams.put("teacherName", teacher.getNickname());
+                templateParams.put("date",yesterday.toString());
 
-                // 创建 ByteArrayOutputStream 用来存储 Word 文件数据
-                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-                   // 创建 Word 文档
+                // 创建 Word 文档
                 XWPFDocument document = new XWPFDocument();
 
-                createParagraphWithRun(document, "测绘地理信息学院研究生考勤情况日报告", 16,  ParagraphAlignment.CENTER, 100,0);
+                createParagraphWithRun(document, "测绘地理信息学院研究生考勤情况日报告", 16, ParagraphAlignment.CENTER, 100, 0);
 
-                createParagraphWithRun(document, "尊敬的"+teacher.getNickname()+"导师(家长):", 14,  ParagraphAlignment.LEFT, 100, UnderlinePatterns.SINGLE);
+                createParagraphWithRun(document, "尊敬的" + teacher.getNickname() + "老师:", 14, ParagraphAlignment.LEFT, 100, UnderlinePatterns.SINGLE);
 
                 String dateInfoText = "         您所指导的研究生 " + yesterday.getYear() + " 年 " + yesterday.getMonthValue() + " 月 " + yesterday.getDayOfMonth() + " 日 考勤情况如下:";
-                createParagraphWithRun(document, dateInfoText, 14,  ParagraphAlignment.LEFT, 60,0);
+                createParagraphWithRun(document, dateInfoText, 14, ParagraphAlignment.LEFT, 60, 0);
 
-                // 未打卡同学清单标题
-                createParagraphWithRun(document, "未打卡同学清单", 14,  ParagraphAlignment.CENTER, 50,0);
-                // 未打卡同学数据填写
-                createAttendanceTable(document, errorList, false);
+                StringBuilder normalListBuilder = new StringBuilder();
+                for (StudentAttendanceSupervisorTemplateVO attendance : normalList) {
+                    normalListBuilder
+                            .append(" 学生姓名: ").append(attendance.getStudentName())
+                            .append(" 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
+                            .append(" 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "未打卡")
+                            .append("<br/>");
+                }
+
+                StringBuilder errorListBuilder = new StringBuilder();
+                for (StudentAttendanceSupervisorTemplateVO attendance : errorList) {
+                    errorListBuilder
+                            .append(" 学生姓名: ").append(attendance.getStudentName())
+                            .append(" 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
+                            .append(" 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "未打卡")
+                            .append("<br/>");
+                }
 
 
-                createParagraphWithRun(document, "特此通知,请您及时检查学生在校情况。", 14,  ParagraphAlignment.LEFT, 1000,0);
+                if (!errorList.isEmpty()) {
+                    templateParams.put("errType","未打卡同学清单");
+                    templateParams.put("errList",errorListBuilder);
+                    // 未打卡同学清单标题
+                    createParagraphWithRun(document, "未打卡同学清单", 14, ParagraphAlignment.CENTER, 50, 0);
+                    // 未打卡同学数据填写
+                    createAttendanceTable(document, errorList, false);
 
-                createParagraphWithRun(document, "测绘地理信息学院研究生管理委员会", 14,  ParagraphAlignment.RIGHT, 100,1000);
+                    createParagraphWithRun(document, "特此通知,请您及时检查学生在校情况。", 14, ParagraphAlignment.LEFT, 1000, 0);
 
-                // 正常打卡同学清单标题
-                createParagraphWithRun(document, "正常打卡同学清单", 14,  ParagraphAlignment.CENTER, 0,0);
-                // 正常打卡同学数据填写
-                createAttendanceTable(document, normalList, true);
+                    createParagraphWithRun(document, "测绘地理信息学院研究生管理委员会", 14, ParagraphAlignment.RIGHT, 100, 1000);
+                } else {
+
+                    templateParams.put("errType","无未打卡记录!");
+                    templateParams.put("errList","");
+                    createParagraphWithRun(document, "无未打卡记录!", 14, ParagraphAlignment.CENTER, 0, 20);
+                }
+
+                if(!normalList.isEmpty()){
+                    templateParams.put("normaltype","正常打卡同学清单");
+                    templateParams.put("normalList",normalListBuilder);
+                    // 正常打卡同学清单标题
+                    createParagraphWithRun(document, "正常打卡同学清单", 14, ParagraphAlignment.CENTER, 0, 0);
+                    // 正常打卡同学数据填写
+                    createAttendanceTable(document, normalList, true);
+                }else{
+                    templateParams.put("normaltype","无人进行打卡!");
+                    templateParams.put("normalList","");
+                    createParagraphWithRun(document, "无人进行打卡!", 14, ParagraphAlignment.CENTER, 0, 20);
+                }
 
                 document.write(byteArrayOutputStream);
 
                 Map<String, InputStream> attachments = new HashMap<>();
-                String fileName = String.format("%s考勤信息.docx", (teacher.getDeptId()==null||teacher.getDeptId()==0?"":teacher.getDeptName())+yesterday);
+                String fileName = String.format("%s考勤信息.docx", (teacher.getDeptId() == null || teacher.getDeptId() == 0 ? "" : teacher.getDeptName()) + yesterday);
                 attachments.put(fileName, new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
                 // 发送邮件,包含附件
                 if (teacher.getEmail() != null) {
-                    mailSendService.sendSingleMailToMemberWithAttachments(teacher.getEmail(), null, "attendance-list-excel", templateParams, attachments);
+                    mailSendService.sendSingleMailToMemberWithAttachments(teacher.getEmail(), null, "attendance-list-word", templateParams, attachments);
                 }
                 // 每次推送后等待0.1s
                 try {
@@ -221,9 +260,9 @@ public class MailTemplateController {
     @Operation(summary = "发送Excel给学院")
     public void sendExcelMailToCollege() throws IOException {
         UserPageReqVO reqVO = new UserPageReqVO();
-        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+        Set<Long> collegeIdList = permissionService.getUserListByRoleId(114L);
 
-        Set<AdminUserDO> collegeList  = new HashSet<>();
+        Set<AdminUserDO> collegeList = new HashSet<>();
         List<AdminUserDO> collegeList1 = adminUserService.getUserList(collegeIdList);
         reqVO.setUserType("4");
         List<AdminUserDO> collegeList2 = adminUserService.getUserList(reqVO);
@@ -231,13 +270,13 @@ public class MailTemplateController {
         collegeList.addAll(collegeList1);
         collegeList.addAll(collegeList2);
 
-        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+        StudentAttendancePageReqVO attendanceReqVO = new StudentAttendancePageReqVO();
 
-        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
+        Map<String, Object> templateParams = new HashMap<>();//模板参数设置
 
         // 获取前一天
         LocalDate yesterday = LocalDate.now().minusDays(1);
-        if ( !collegeList.isEmpty()) {
+        if (!collegeList.isEmpty()) {
             for (AdminUserDO college : collegeList) {
 
                 attendanceReqVO.setDate(yesterday);
@@ -280,7 +319,7 @@ public class MailTemplateController {
                 // 附件
                 Map<String, InputStream> attachments = new HashMap<>();
                 // 创建附件
-                attachments.put(yesterday + "_" + "考勤信息.xlsx" , new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
+                attachments.put(yesterday + "_" + "考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
 
                 // 发送邮件,包含附件
                 if (college.getEmail() != null) {
@@ -296,12 +335,12 @@ public class MailTemplateController {
     public void testTeacher() {
 
         // 获取导师
-        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+        Set<Long> collegeIdList = permissionService.getUserListByRoleId(114L);
         List<AdminUserDO> TeacherList = adminUserService.getUserList(collegeIdList);
 
 
-        StudentAttendancePageReqVO pageReqVO =new StudentAttendancePageReqVO();
-        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
+        StudentAttendancePageReqVO pageReqVO = new StudentAttendancePageReqVO();
+        Map<String, Object> templateParams = new HashMap<>();//模板参数设置
 
         // 获取前一天
         LocalDate yesterday = LocalDate.now().minusDays(1);
@@ -310,7 +349,7 @@ public class MailTemplateController {
 //            return; // 直接返回,不推送周日的
 //        }
 
-        if ( TeacherList!=null&& !TeacherList.isEmpty()) {
+        if (TeacherList != null && !TeacherList.isEmpty()) {
             for (AdminUserDO teacher : TeacherList) {
                 if (teacher.getDeptId() == null || teacher.getDeptId() == 0) {
                     return;
@@ -375,9 +414,9 @@ public class MailTemplateController {
     @Operation(summary = "测试发送邮件给学院")
     public void testCollege() {
         UserPageReqVO reqVO = new UserPageReqVO();
-        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+        Set<Long> collegeIdList = permissionService.getUserListByRoleId(114L);
 
-        Set<AdminUserDO> collegeList  = new HashSet<>();
+        Set<AdminUserDO> collegeList = new HashSet<>();
         List<AdminUserDO> collegeList1 = adminUserService.getUserList(collegeIdList);
         reqVO.setUserType("4");
         List<AdminUserDO> collegeList2 = adminUserService.getUserList(reqVO);
@@ -385,11 +424,11 @@ public class MailTemplateController {
         collegeList.addAll(collegeList1);
         collegeList.addAll(collegeList2);
 
-       //找学院
+        //找学院
 
-        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+        StudentAttendancePageReqVO attendanceReqVO = new StudentAttendancePageReqVO();
 
-        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
+        Map<String, Object> templateParams = new HashMap<>();//模板参数设置
 
         // 获取前一天
         LocalDate yesterday = LocalDate.now().minusDays(1);
@@ -398,7 +437,7 @@ public class MailTemplateController {
 //            return; // 直接返回,不推送周日的
 //        }
 
-        if ( !collegeList.isEmpty()) {
+        if (!collegeList.isEmpty()) {
             for (AdminUserDO college : collegeList) {
 
                 attendanceReqVO.setDate(yesterday);
@@ -420,8 +459,8 @@ public class MailTemplateController {
                     normalListBuilder
                             .append(", 学生姓名: ").append(attendance.getStudentName())
                             .append(", 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
-                            .append(", 工作间名称: ").append(attendance.getDeptName()!=null?attendance.getDeptName():"无")
-                            .append(", 导师名称:").append(attendance.getSupervisor()!=null ? attendance.getSupervisor():"无" )
+                            .append(", 工作间名称: ").append(attendance.getDeptName() != null ? attendance.getDeptName() : "无")
+                            .append(", 导师名称:").append(attendance.getSupervisor() != null ? attendance.getSupervisor() : "无")
                             .append(", 日期: ").append(attendance.getDate())
                             .append(", 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "未打卡")
                             .append("<br/>");
@@ -432,8 +471,8 @@ public class MailTemplateController {
                     errorListBuilder
                             .append(", 学生姓名: ").append(attendance.getStudentName())
                             .append(", 学生学号: ").append(attendance.getUserNumber() != null ? attendance.getUserNumber() : "无")
-                            .append(", 工作间名称: ").append(attendance.getDeptName()!=null?attendance.getDeptName():"无")
-                            .append(", 导师名称:").append(attendance.getSupervisor()!=null ? attendance.getSupervisor():"无" )
+                            .append(", 工作间名称: ").append(attendance.getDeptName() != null ? attendance.getDeptName() : "无")
+                            .append(", 导师名称:").append(attendance.getSupervisor() != null ? attendance.getSupervisor() : "无")
                             .append(", 日期: ").append(attendance.getDate())
                             .append(", 打卡时间: ").append(attendance.getClockInTime() != null ? attendance.getClockInTime() : "未打卡")
                             .append("<br/>");
@@ -500,38 +539,38 @@ public class MailTemplateController {
 //                        .collect(Collectors.toList());
 
                 // 创建 ByteArrayOutputStream 用来存储 Word 文件数据
-            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 // 创建 Word 文档
-            XWPFDocument document = new XWPFDocument();
+                XWPFDocument document = new XWPFDocument();
 
-            createParagraphWithRun(document, "测绘地理信息学院研究生考勤情况日报告", 16,  ParagraphAlignment.CENTER, 100,0);
+                createParagraphWithRun(document, "测绘地理信息学院研究生考勤情况日报告", 16, ParagraphAlignment.CENTER, 100, 0);
 
-            createParagraphWithRun(document, "尊敬的"+teacher.getNickname()+"导师(家长):", 14,  ParagraphAlignment.LEFT, 100, UnderlinePatterns.SINGLE);
+                createParagraphWithRun(document, "尊敬的" + teacher.getNickname() + "导师(家长):", 14, ParagraphAlignment.LEFT, 100, UnderlinePatterns.SINGLE);
 
-            String dateInfoText = "         您所指导的研究生 " + yesterday.getYear() + " 年 " + yesterday.getMonthValue() + " 月 " + yesterday.getDayOfMonth() + " 日 考勤情况如下:";
-            createParagraphWithRun(document, dateInfoText, 14,  ParagraphAlignment.LEFT, 60,0);
+                String dateInfoText = "         您所指导的研究生 " + yesterday.getYear() + " 年 " + yesterday.getMonthValue() + " 月 " + yesterday.getDayOfMonth() + " 日 考勤情况如下:";
+                createParagraphWithRun(document, dateInfoText, 14, ParagraphAlignment.LEFT, 60, 0);
 
-            createParagraphWithRun(document, "未打卡同学清单", 14,  ParagraphAlignment.CENTER, 50,0);
+                createParagraphWithRun(document, "未打卡同学清单", 14, ParagraphAlignment.CENTER, 50, 0);
 
-            createAttendanceTable(document, errorList, false);
+                createAttendanceTable(document, errorList, false);
 
 
-            createParagraphWithRun(document, "特此通知,请您及时检查学生在校情况。", 14,  ParagraphAlignment.LEFT, 1000,0);
+                createParagraphWithRun(document, "特此通知,请您及时检查学生在校情况。", 14, ParagraphAlignment.LEFT, 1000, 0);
 
-            createParagraphWithRun(document, "测绘地理信息学院研究生管理委员会", 14,  ParagraphAlignment.RIGHT, 100,1000);
+                createParagraphWithRun(document, "测绘地理信息学院研究生管理委员会", 14, ParagraphAlignment.RIGHT, 100, 1000);
 
-            // 正常打卡同学清单标题
-            createParagraphWithRun(document, "正常打卡同学清单", 14,  ParagraphAlignment.CENTER, 0,0);
-            // 正常打卡同学数据填写
-            createAttendanceTable(document, normalList, true);
+                // 正常打卡同学清单标题
+                createParagraphWithRun(document, "正常打卡同学清单", 14, ParagraphAlignment.CENTER, 0, 0);
+                // 正常打卡同学数据填写
+                createAttendanceTable(document, normalList, true);
 
-            document.write(byteArrayOutputStream);
+                document.write(byteArrayOutputStream);
 
-            // 创建附件并将文件保存
-            Map<String, InputStream> attachments = new HashMap<>();
+                // 创建附件并将文件保存
+                Map<String, InputStream> attachments = new HashMap<>();
 //            String fileName = String.format("%s考勤信息.docx", (teacher.getDeptId()==null||teacher.getDeptId()==0?"":teacher.getDeptName())+yesterday);
-            String fileName = String.format("%s考勤信息.docx", yesterday);
-            attachments.put(fileName, new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
+                String fileName = String.format("%s考勤信息.docx", yesterday);
+                attachments.put(fileName, new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
                 // 发送邮件
                 if (teacher.getEmail() != null) {
                     mailSendService.sendSingleMailToMemberWithAttachments(email, null, "attendance-list-excel", templateParams, attachments);
@@ -550,9 +589,9 @@ public class MailTemplateController {
     @Operation(summary = "测试发送Excel给学院")
     public void ceshiExcelToCollege(@RequestParam("email") String email) throws IOException {
         UserPageReqVO reqVO = new UserPageReqVO();
-        Set<Long> collegeIdList =  permissionService.getUserListByRoleId(114L);
+        Set<Long> collegeIdList = permissionService.getUserListByRoleId(114L);
 
-        Set<AdminUserDO> collegeList  = new HashSet<>();
+        Set<AdminUserDO> collegeList = new HashSet<>();
         List<AdminUserDO> collegeList1 = adminUserService.getUserList(collegeIdList);
         reqVO.setUserType("4");
         List<AdminUserDO> collegeList2 = adminUserService.getUserList(reqVO);
@@ -560,13 +599,13 @@ public class MailTemplateController {
         collegeList.addAll(collegeList1);
         collegeList.addAll(collegeList2);
         //找学院
-        StudentAttendancePageReqVO attendanceReqVO =new StudentAttendancePageReqVO();
+        StudentAttendancePageReqVO attendanceReqVO = new StudentAttendancePageReqVO();
 
-        Map<String, Object> templateParams =new HashMap<>();//模板参数设置
+        Map<String, Object> templateParams = new HashMap<>();//模板参数设置
 
         // 获取前一天
         LocalDate yesterday = LocalDate.now().minusDays(1);
-        if ( !collegeList.isEmpty()) {
+        if (!collegeList.isEmpty()) {
             for (AdminUserDO college : collegeList) {
 
                 attendanceReqVO.setDate(yesterday);
@@ -609,7 +648,7 @@ public class MailTemplateController {
 
                 Map<String, InputStream> attachments = new HashMap<>();
                 // 使用 ByteArrayInputStream 来创建附件
-                attachments.put(yesterday+"_"+"考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
+                attachments.put(yesterday + "_" + "考勤信息.xlsx", new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
 
                 // 发送邮件,包含附件
                 if (college.getEmail() != null) {
@@ -621,7 +660,7 @@ public class MailTemplateController {
 
 
     // 方法: 创建带有文本的段落
-    private void createParagraphWithRun(XWPFDocument document, String text, int fontSize,  ParagraphAlignment alignment, int spacingAfter,int spacingBefore) {
+    private void createParagraphWithRun(XWPFDocument document, String text, int fontSize, ParagraphAlignment alignment, int spacingAfter, int spacingBefore) {
         XWPFParagraph paragraph = document.createParagraph();
         XWPFRun run = paragraph.createRun();
         run.setText(text);
@@ -633,7 +672,7 @@ public class MailTemplateController {
     }
 
     // 方法: 创建带有文本和下划线的段落
-    private void createParagraphWithRun(XWPFDocument document, String text, int fontSize,  ParagraphAlignment alignment, int spacingAfter, UnderlinePatterns underlinePattern) {
+    private void createParagraphWithRun(XWPFDocument document, String text, int fontSize, ParagraphAlignment alignment, int spacingAfter, UnderlinePatterns underlinePattern) {
         XWPFParagraph paragraph = document.createParagraph();
         XWPFRun run = paragraph.createRun();
         run.setText(text);
@@ -691,4 +730,77 @@ public class MailTemplateController {
         }
     }
 
+
+    /**
+     * 生成用于展示的考勤报告文字内容
+     *
+     * @param teacher    导师信息
+     * @param normalList 正常打卡学生列表
+     * @param errorList  未打卡学生列表
+     * @param date       报告日期
+     * @return 生成的文字内容
+     */
+    public String generateAttendanceReportText(AdminUserDO teacher,
+                                               List<StudentAttendanceSupervisorTemplateVO> normalList,
+                                               List<StudentAttendanceSupervisorTemplateVO> errorList,
+                                               LocalDate date) {
+        StringBuilder report = new StringBuilder();
+
+        // 标题
+        report.append("测绘地理信息学院研究生考勤情况日报告").append("\n\n");
+
+        // 问候语
+        report.append("尊敬的").append(teacher.getNickname()).append("老师:").append("\n\n");
+
+        // 时间信息
+        report.append("         您所指导的研究生 ")
+                .append(date.getYear()).append(" 年 ")
+                .append(date.getMonthValue()).append(" 月 ")
+                .append(date.getDayOfMonth()).append(" 日考勤情况如下:").append("\n\n");
+
+        // 未打卡学生清单
+        if (errorList != null && !errorList.isEmpty()) {
+            report.append("未打卡同学清单").append("\n");
+            report.append(generateAttendanceTable(errorList, false)).append("\n");
+            report.append("特此通知,请您及时检查学生在校情况。").append("\n\n");
+            report.append("测绘地理信息学院研究生管理委员会").append("\n");
+            report.append(date.toString()).append("\n\n");
+        } else {
+            report.append("您所指导的所有研究生今日已全部打卡!").append("\n\n");
+            report.append("测绘地理信息学院研究生管理委员会").append("\n");
+            report.append(date.toString()).append("\n\n");
+        }
+
+        // 正常打卡学生清单
+        report.append("正常打卡同学清单").append("\n");
+        report.append(generateAttendanceTable(normalList, true));
+
+        return report.toString();
+    }
+
+    /**
+     * 生成考勤表格内容
+     *
+     * @param dataList     学生考勤数据列表
+     * @param isNormalList 是否为正常打卡名单
+     * @return 表格文字内容
+     */
+    private String generateAttendanceTable(List<StudentAttendanceSupervisorTemplateVO> dataList, boolean isNormalList) {
+        StringBuilder table = new StringBuilder();
+
+        // 表头
+        table.append(String.format("%-5s%-10s%-15s%-15s%-15s%n", "序号", "学生姓名", "学生学号", "所在实验室房号", isNormalList ? "打卡时间" : "备注"));
+
+        // 填充数据
+        int sequenceNumber = 1;
+        for (StudentAttendanceSupervisorTemplateVO vo : dataList) {
+            table.append(String.format("%-5d%-10s%-15s%-15s%-15s%n",
+                    sequenceNumber++, vo.getStudentName(), vo.getUserNumber(), vo.getDeptName(),
+                    isNormalList ? vo.getClockInTime() : vo.getRemark()));
+        }
+
+        return table.toString();
+
+    }
+
 }

+ 2 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@@ -252,6 +252,8 @@ public interface AdminUserService {
     void updateUserIntroduction(String introduction);
 
     List<AdminUserDO> getStudentAndSupervisorNull(String grade);
+
+    Boolean isSupervisorNullHasStudent(Long teacherId);
 }
 
 

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -1198,5 +1198,11 @@ public class AdminUserServiceImpl implements AdminUserService {
     public List<AdminUserDO> getStudentAndSupervisorNull(String grade){
         return userMapper.getStudentAndSupervisorNull(grade);
     }
+    @Override
+    public Boolean isSupervisorNullHasStudent(Long teacherId){
+        List<AdminUserDO> list = userMapper.selectList(new LambdaQueryWrapperX<AdminUserDO>().eq(AdminUserDO::getSupervisorId,teacherId));
+        return !list.isEmpty();
+    }
+
 }