Parcourir la source

定时重启设备

yzx il y a 2 mois
Parent
commit
62119f018a

+ 1 - 1
.gitignore

@@ -1,6 +1,6 @@
 ######################################################################
 # Build Tools
-
+.DS_Store
 .gradle
 /build/
 !gradle/wrapper/gradle-wrapper.jar

+ 1 - 1
yudao-module-md/yudao-module-md-biz/src/main/java/cn/iocoder/yudao/module/md/controller/admin/AcsController.java

@@ -76,7 +76,7 @@ public class AcsController {
         acsService.searchEvents(adminUserService, studentAttendanceService,fileApi);
     }
 
-/**
+    /**
      * 添加用户
      */
     @PostMapping("/addUser")

+ 15 - 0
yudao-module-md/yudao-module-md-biz/src/main/java/cn/iocoder/yudao/module/md/service/AcsService.java

@@ -24,8 +24,10 @@ import com.sun.jna.Native;
 import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
 import org.apache.tomcat.util.http.fileupload.FileUtils;
 import org.json.JSONException;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.PostConstruct;
@@ -59,6 +61,19 @@ public class AcsService {
     @Resource
     private AdminUserService userService;
 
+
+    @Scheduled(cron = "0 */1 * * * ?") // 每10分钟执行
+    @PostMapping("/getMachineList")
+    public void scheduledTask() {
+        if (lUserID >= 0) {
+            hCNetSDK.NET_DVR_Logout(lUserID);
+        }
+        boolean isSuccess = hCNetSDK.NET_DVR_Cleanup();
+        if(isSuccess){
+            init();
+        }
+    }
+
     /**
      * 初始化 SDK 并登录设备
      */

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

@@ -160,10 +160,10 @@ public class MailTemplateController {
                         studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO.setSupervisorId(getLoginUserId())),
                         StudentAttendanceSupervisorTemplateVO.class
                 );
-                List<StudentAttendanceSupervisorTemplateVO> excusedList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setSupervisorId(getLoginUserId())),
-                        StudentAttendanceSupervisorTemplateVO.class
-                );
+//                List<StudentAttendanceSupervisorTemplateVO> excusedList = BeanUtils.toBean(
+//                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO.setSupervisorId(getLoginUserId())),
+//                        StudentAttendanceSupervisorTemplateVO.class
+//                );
                 // 创建 ByteArrayOutputStream 用来存储 Excel 文件数据
                 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 
@@ -171,12 +171,12 @@ public class MailTemplateController {
                 try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceSupervisorTemplateVO.class).build()) {
                     WriteSheet writeSheetNormal = EasyExcel.writerSheet("正常打卡信息").build();
                     WriteSheet writeSheetError = EasyExcel.writerSheet("未打卡信息").build();
-                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
+//                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
 
                     // 将各个 List 数据写入不同的 Sheet 中
                     excelWriter.write(normalList, writeSheetNormal);
                     excelWriter.write(errorList, writeSheetError);
-                    excelWriter.write(excusedList, writeSheetExcused);
+//                    excelWriter.write(excusedList, writeSheetExcused);
                 }
 
                 // 创建附件 Map
@@ -229,14 +229,14 @@ public class MailTemplateController {
                         })
                         .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());
+//                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();
@@ -245,11 +245,11 @@ public class MailTemplateController {
                 try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceCollegeTemplateVO.class).build()) {
                     WriteSheet writeSheetNormal = EasyExcel.writerSheet("正常打卡信息").build();
                     WriteSheet writeSheetError = EasyExcel.writerSheet("未打卡信息").build();
-                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
+//                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
 
                     excelWriter.write(normalList, writeSheetNormal);
                     excelWriter.write(errorList, writeSheetError);
-                    excelWriter.write(excusedList, writeSheetExcused);
+//                    excelWriter.write(excusedList, writeSheetExcused);
                 }
 
                 // 附件
@@ -300,10 +300,10 @@ public class MailTemplateController {
                         studentAttendanceService.getStudentAttendanceErrorListForTeacher(pageReqVO),
                         StudentAttendanceEmailVO.class
                 );
-                List<StudentAttendanceEmailVO> excusedList = BeanUtils.toBean(
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO),
-                        StudentAttendanceEmailVO.class
-                );
+//                List<StudentAttendanceEmailVO> excusedList = BeanUtils.toBean(
+//                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(pageReqVO),
+//                        StudentAttendanceEmailVO.class
+//                );
 
                 StringBuilder normalListBuilder = new StringBuilder();
                 for (StudentAttendanceEmailVO attendance : normalList) {
@@ -325,19 +325,19 @@ public class MailTemplateController {
                             .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/>");
-                }
+//                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());
+//                templateParams.put("excusedList", excusedListBuilder.toString());
                 if (teacher.getEmail() != null) {
                     mailSendService.sendSingleMailToMember(teacher.getEmail(), null, "attendance-list", templateParams);
                 }
@@ -385,10 +385,10 @@ public class MailTemplateController {
                         studentAttendanceService.getStudentAttendanceErrorListForTeacher(attendanceReqVO),
                         StudentAttendanceEmailVO.class
                 );
-                List<StudentAttendanceEmailVO> excusedList = BeanUtils.toBean(//请假
-                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(attendanceReqVO),
-                        StudentAttendanceEmailVO.class
-                );
+//                List<StudentAttendanceEmailVO> excusedList = BeanUtils.toBean(//请假
+//                        studentAttendanceService.getStudentAttendanceExcusedListForTeacher(attendanceReqVO),
+//                        StudentAttendanceEmailVO.class
+//                );
 
                 StringBuilder normalListBuilder = new StringBuilder();
                 for (StudentAttendanceEmailVO attendance : normalList) {
@@ -414,21 +414,21 @@ public class MailTemplateController {
                             .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.getDeptName()!=null?attendance.getDeptName():"无")
-                            .append(", 导师名称:").append(attendance.getSupervisor()!=null ? attendance.getSupervisor():"无" )
-                            .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.getDeptName()!=null?attendance.getDeptName():"无")
+//                            .append(", 导师名称:").append(attendance.getSupervisor()!=null ? attendance.getSupervisor():"无" )
+//                            .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());
+//                templateParams.put("excusedList", excusedListBuilder.toString());
                 if (college.getEmail() != null) {
                     mailSendService.sendSingleMailToMember(college.getEmail(), null, "attendance-list", templateParams);
                 }
@@ -468,14 +468,14 @@ public class MailTemplateController {
                         })
                         .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());
+//                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();
@@ -489,7 +489,7 @@ public class MailTemplateController {
 
                     excelWriter.write(normalList, writeSheetNormal);
                     excelWriter.write(errorList, writeSheetError);
-                    excelWriter.write(excusedList, writeSheetExcused);
+//                    excelWriter.write(excusedList, writeSheetExcused);
                 }
 
                 // 创建附件 Map
@@ -542,14 +542,14 @@ public class MailTemplateController {
                         })
                         .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());
+//                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();
@@ -558,12 +558,12 @@ public class MailTemplateController {
                 try (ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, StudentAttendanceCollegeTemplateVO.class).build()) {
                     WriteSheet writeSheetNormal = EasyExcel.writerSheet("正常打卡信息").build();
                     WriteSheet writeSheetError = EasyExcel.writerSheet("未打卡信息").build();
-                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
+//                    WriteSheet writeSheetExcused = EasyExcel.writerSheet("请假信息").build();
 
                     // 将各个 List 数据写入不同的 Sheet 中
                     excelWriter.write(normalList, writeSheetNormal);
                     excelWriter.write(errorList, writeSheetError);
-                    excelWriter.write(excusedList, writeSheetExcused);
+//                    excelWriter.write(excusedList, writeSheetExcused);
                 }
 
                 Map<String, InputStream> attachments = new HashMap<>();

+ 2 - 1
yudao-server/src/main/resources/application-local.yaml

@@ -47,6 +47,7 @@ spring:
       datasource:
         master:
           url: jdbc:mysql://172.16.59.50:3306/graduate?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
+#          url: jdbc:mysql://127.0.0.1:3306/graduate?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
           #          url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例
           #          url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例
           #          url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
@@ -70,7 +71,7 @@ spring:
 
   # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
   redis:
-    host: 172.16.59.50 # 地址
+    host: 172.16.59.50  # 地址
     port: 6379 # 端口
     database: 2 # 数据库索引
     password: 123456 # 密码,建议生产环境开启