Quellcode durchsuchen

学生、教师导入

brealinxx vor 1 Jahr
Ursprung
Commit
6ae8f4ab14

+ 4 - 1
src/main/java/com/xjrsoft/module/attendance/mapper/AttendanceRuleDetailsMapper.java

@@ -3,6 +3,9 @@ package com.xjrsoft.module.attendance.mapper;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
 * @title: 考勤规则细则
@@ -12,5 +15,5 @@ import org.apache.ibatis.annotations.Mapper;
 */
 @Mapper
 public interface AttendanceRuleDetailsMapper extends MPJBaseMapper<AttendanceRuleDetails> {
-
+    List<AttendanceRuleDetails> getTodayRules(@Param("dayOfWeek") String dayOfWeek);
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/attendance/service/IAttendanceRuleCategoryService.java

@@ -4,6 +4,7 @@ import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.attendance.dto.AddAttendanceRuleCategoryDto;
 import com.xjrsoft.module.attendance.dto.UpdateAttendanceRuleCategoryDto;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleCategory;
+import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
 
 import java.util.List;
 
@@ -38,4 +39,6 @@ public interface IAttendanceRuleCategoryService extends MPJBaseService<Attendanc
     * @return
     */
     Boolean delete(List<Long> ids);
+
+    List<AttendanceRuleDetails> getTodayRules();
 }

+ 9 - 0
src/main/java/com/xjrsoft/module/attendance/service/impl/AttendanceRuleCategoryServiceImpl.java

@@ -30,6 +30,8 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.DayOfWeek;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -406,4 +408,11 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
 
         return true;
     }
+
+    @Override
+    public List<AttendanceRuleDetails> getTodayRules() {
+        LocalDateTime now = LocalDateTime.now();
+        DayOfWeek dayOfWeek = now.getDayOfWeek();
+        return detailsMapper.getTodayRules(dayOfWeek.name());
+    }
 }

+ 6 - 6
src/main/java/com/xjrsoft/module/hikvision/util/Teacher_Student_OutIn_RecordUtil.java

@@ -17,24 +17,24 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class Teacher_Student_OutIn_RecordUtil {
     public void teacherInsertRecord(Db db, Long userId, String recordTime, String facePhoto,int status, String eventId) throws SQLException {
 
-        String sql = "INSERT INTO teacher_out_in_record(create_date, user_id, record_time, face_photo, eventId, status) " +
+        String sql = "INSERT INTO teacher_out_in_record(create_date, user_id, record_time, face_photo, eventId, status,delete_mark,enabled_mark) " +
                 "VALUES(now(), '"  + userId + "', '" + recordTime + "', '" +
-                facePhoto + "', '" + eventId + "', '" +status + "')";
+                facePhoto + "', '" + eventId + "', '" +status + "',0,1)";
         db.execute(sql);
     }
 
     public void studentInsertRecord(Db db, Long userId, Long teacherId, Long classId, String facePhoto, String recordTime, int status, String eventId) throws SQLException {
-        String sql = "INSERT INTO student_out_in_record(create_date, user_id, teacher_id, class_id, face_photo, record_time , eventId,status) " +
+        String sql = "INSERT INTO student_out_in_record(create_date, user_id, teacher_id, class_id, face_photo, record_time , eventId,status,delete_mark,enabled_mark) " +
                 "VALUES(now(), '" + userId + "', '" + teacherId + "', '" +
-                classId + "', '" + facePhoto + "', '" + recordTime + "', '" + eventId + "', '" + status + "')";
+                classId + "', '" + facePhoto + "', '" + recordTime + "', '" + eventId + "', '" + status + "',0,1)";
         db.execute(sql);
     }
 
 
     public void visitInsertRecord(Db db, Long reservation_school_people_id, String recordTime,Long facePhoto, int status) throws SQLException {
-        String sql = "INSERT INTO visitor_out_in_record(create_date, reservation_school_people_id, record_time, face_photo, status) " +
+        String sql = "INSERT INTO visitor_out_in_record(create_date, reservation_school_people_id, record_time, face_photo, status,delete_mark,enabled_mark) " +
                 "VALUES(now(), '"  + reservation_school_people_id + "', '" +
-                 recordTime + "', '" + facePhoto + "', '" + status +  "')";
+                 recordTime + "', '" + facePhoto + "', '" + status +  "',0,1)";
         db.execute(sql);
     }
 

+ 45 - 0
src/main/java/com/xjrsoft/module/job/AttendanceMessageTask.java

@@ -0,0 +1,45 @@
+package com.xjrsoft.module.job;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.xjrsoft.common.constant.GlobalConstant;
+import com.xjrsoft.common.utils.DatasourceUtil;
+import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
+import com.xjrsoft.module.attendance.service.IAttendanceMessageSetService;
+import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.sql.DataSource;
+import java.util.List;
+
+/**
+ * 考勤消息通知
+ * @author dzx
+ * @date 2024年5月21日
+ */
+@Component
+@Slf4j
+public class AttendanceMessageTask {
+    @Autowired
+    private IAttendanceMessageSetService messageSetService;
+
+    @Autowired
+    private IAttendanceRuleCategoryService ruleCategoryService;
+    @Scheduled(cron = "0 */15 * * * ?")
+    public void RefreshConnectionPool() {
+        String active = SpringUtil.getActiveProfile();
+        if(!"prod".equals(active)){
+            log.info("非正式环境,无法执行数据推送");
+            return;
+        }
+
+        List<AttendanceRuleDetails> ruleDetails = ruleCategoryService.getTodayRules();
+
+        try {
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+    }
+}

+ 0 - 8
src/main/java/com/xjrsoft/module/outint/controller/CarOutInRecordController.java

@@ -1,11 +1,9 @@
 package com.xjrsoft.module.outint.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
-import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.xjrsoft.common.model.result.RT;
@@ -20,13 +18,8 @@ import com.xjrsoft.module.outint.service.ICarOutInRecordService;
 import com.xjrsoft.module.outint.vo.CarOutInRecordPageVo;
 import com.xjrsoft.module.outint.vo.CarOutInRecordVo;
 import com.xjrsoft.module.personnel.entity.CarMessageApply;
-import com.xjrsoft.module.personnel.entity.ReservationSchool;
 import com.xjrsoft.module.personnel.entity.ReservationSchoolPeople;
-import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
-import com.xjrsoft.module.personnel.vo.ReservationSchoolVisitorPageVo;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
-import com.xjrsoft.module.system.entity.File;
-import com.xjrsoft.module.teacher.entity.XjrUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -78,7 +71,6 @@ public class CarOutInRecordController {
                         .select(CarMessageApply::getVehicleType)
                         .leftJoin(ReservationSchoolPeople.class,ReservationSchoolPeople::getId,CarOutInRecord::getReservationSchoolPeopleId)
                         .leftJoin(CarMessageApply.class,CarMessageApply::getId,CarOutInRecord::getCarMessageApplyId)
-                        .leftJoin(File.class,File::getFolderId, CarOutInRecord::getFacePhoto,ext->ext.selectAs(File::getFileUrl,CarOutInRecordPageVo::getFacePhotoUrl))
                         .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode, ReservationSchoolPeople::getGender, ext->ext.selectAs(DictionaryDetail::getName, CarOutInRecordPageVo::getGender))
                 );
 

+ 0 - 5
src/main/java/com/xjrsoft/module/outint/controller/StudentOutInRecordController.java

@@ -4,7 +4,6 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -17,14 +16,11 @@ import com.xjrsoft.module.outint.dto.AddStudentOutInRecordDto;
 import com.xjrsoft.module.outint.dto.StudentOutInRecordPageDto;
 import com.xjrsoft.module.outint.dto.UpdateStudentOutInRecordDto;
 import com.xjrsoft.module.outint.entity.StudentOutInRecord;
-import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
 import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
 import com.xjrsoft.module.outint.vo.StudentOutInRecordPageVo;
 import com.xjrsoft.module.outint.vo.StudentOutInRecordVo;
-import com.xjrsoft.module.outint.vo.TeacherOutInRecordPageVo;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
-import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -79,7 +75,6 @@ public class StudentOutInRecordController {
                 .leftJoin(BaseStudentSchoolRoll.class,BaseStudentSchoolRoll::getUserId,StudentOutInRecord::getUserId)
                 .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode, XjrUser::getGender, ext->ext.selectAs(DictionaryDetail::getName, StudentOutInRecordPageVo::getGender))
                 .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode, BaseStudentSchoolRoll::getStduyStatus, ext->ext.selectAs(DictionaryDetail::getName, StudentOutInRecordPageVo::getStduyStatusCn))
-                .leftJoin(File.class,File::getFolderId, StudentOutInRecord::getFacePhoto, ext->ext.selectAs(File::getFileUrl, StudentOutInRecordPageVo::getFacePhotoUrl))
                 ;
         IPage<StudentOutInRecordPageVo> page = studentOutInRecordService.selectJoinListPage(ConventPage.getPage(dto),StudentOutInRecordPageVo.class, queryWrapper);
         PageOutput<StudentOutInRecordPageVo> pageOutput = ConventPage.getPageOutput(page, StudentOutInRecordPageVo.class);

+ 1 - 10
src/main/java/com/xjrsoft/module/outint/controller/TeacherOutInRecordController.java

@@ -4,9 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.yulichang.interfaces.MPJBaseJoin;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.model.result.RT;
@@ -18,16 +16,10 @@ import com.xjrsoft.module.outint.dto.AddTeacherOutInRecordDto;
 import com.xjrsoft.module.outint.dto.TeacherOutInRecordPageDto;
 import com.xjrsoft.module.outint.dto.UpdateTeacherOutInRecordDto;
 import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
-import com.xjrsoft.module.outint.entity.VisitorOutInRecord;
 import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
 import com.xjrsoft.module.outint.vo.TeacherOutInRecordPageVo;
 import com.xjrsoft.module.outint.vo.TeacherOutInRecordVo;
-import com.xjrsoft.module.outint.vo.VisitorOutInRecordPageVo;
-import com.xjrsoft.module.personnel.entity.ReservationSchool;
-import com.xjrsoft.module.personnel.entity.ReservationSchoolPeople;
-import com.xjrsoft.module.student.entity.BaseStudentAssessmentProject;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
-import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -74,10 +66,9 @@ public class TeacherOutInRecordController {
                 .select(TeacherOutInRecord.class,x -> VoToColumnUtil.fieldsToColumns(TeacherOutInRecordPageVo.class).contains(x.getProperty()))
                 .select(XjrUser::getName,XjrUser::getMobile,XjrUser::getCredentialNumber)
                 .leftJoin(XjrUser.class,XjrUser::getId,TeacherOutInRecord::getUserId)
-                .leftJoin(File.class,File::getFolderId, TeacherOutInRecord::getFacePhoto, ext->ext.selectAs(File::getFileUrl, TeacherOutInRecordPageVo::getFacePhotoUrl))
                 .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode, XjrUser::getGender, ext->ext.selectAs(DictionaryDetail::getName, TeacherOutInRecordPageVo::getGender));
 
-        if(ObjectUtil.isNotNull(dto.getDeptId())&&dto.getDeptId()!=0){
+        if(ObjectUtil.isNotNull(dto.getDeptId()) && dto.getDeptId() != 0){
             queryWrapper.leftJoin(UserDeptRelation.class,UserDeptRelation::getUserId,XjrUser::getId)
                     .eq(UserDeptRelation::getDeptId,dto.getDeptId());
         }

+ 0 - 9
src/main/java/com/xjrsoft/module/outint/controller/VisitorOutInRecordController.java

@@ -4,7 +4,6 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.xjrsoft.common.model.result.RT;
@@ -15,18 +14,13 @@ import com.xjrsoft.module.organization.entity.Department;
 import com.xjrsoft.module.outint.dto.AddVisitorOutInRecordDto;
 import com.xjrsoft.module.outint.dto.UpdateVisitorOutInRecordDto;
 import com.xjrsoft.module.outint.dto.VisitorOutInRecordPageDto;
-import com.xjrsoft.module.outint.entity.CarOutInRecord;
 import com.xjrsoft.module.outint.entity.VisitorOutInRecord;
 import com.xjrsoft.module.outint.service.IVisitorOutInRecordService;
-import com.xjrsoft.module.outint.vo.CarOutInRecordPageVo;
 import com.xjrsoft.module.outint.vo.VisitorOutInRecordPageVo;
 import com.xjrsoft.module.outint.vo.VisitorOutInRecordVo;
-import com.xjrsoft.module.personnel.entity.CarMessageApply;
 import com.xjrsoft.module.personnel.entity.ReservationSchool;
 import com.xjrsoft.module.personnel.entity.ReservationSchoolPeople;
-import com.xjrsoft.module.personnel.vo.ReservationSchoolVisitorPageVo;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
-import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -78,9 +72,6 @@ public class VisitorOutInRecordController {
                         .select(ReservationSchool::getReason)
                         .leftJoin(ReservationSchoolPeople.class,ReservationSchoolPeople::getId,VisitorOutInRecord::getReservationSchoolPeopleId)
                         .leftJoin(ReservationSchool.class,ReservationSchool::getId,ReservationSchoolPeople::getReservationSchooId)
-
-                        .leftJoin(File.class,File::getFolderId, VisitorOutInRecord::getFacePhoto, ext->ext.selectAs(File::getFileUrl, VisitorOutInRecordPageVo::getFacePhotoUrl))
-
                         .leftJoin(XjrUser.class,XjrUser::getId,ReservationSchool::getRespondentUserId,ext->ext.selectAs(XjrUser::getName,VisitorOutInRecordPageVo::getRespondentUserCn))
                         .leftJoin(Department.class,Department::getId,ReservationSchool::getDeptId,ext->ext.selectAs(Department::getName,VisitorOutInRecordPageVo::getDeptCn))
                         .leftJoin(DictionaryDetail.class,DictionaryDetail::getCode, ReservationSchoolPeople::getGender, ext->ext.selectAs(DictionaryDetail::getName, VisitorOutInRecordPageVo::getGender))

+ 4 - 4
src/main/java/com/xjrsoft/module/outint/vo/StudentOutInRecordPageVo.java

@@ -73,7 +73,7 @@ public class StudentOutInRecordPageVo {
     * 人脸照片
     */
     @ApiModelProperty("人脸照片")
-    private Long facePhoto;
+    private String facePhoto;
     /**
     * 进出状态(0:进 1:出)
     */
@@ -116,8 +116,8 @@ public class StudentOutInRecordPageVo {
     @ApiModelProperty("班级")
     private String classCn;
     /**
-     * 班主
+     * 班主
      */
-    @ApiModelProperty("班主")
-    private Long teacherCn;
+    @ApiModelProperty("班主")
+    private String teacherCn;
 }

+ 13 - 0
src/main/resources/mapper/attendance/AttendanceRuleDetailsMapper.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xjrsoft.module.attendance.mapper.AttendanceRuleCategoryMapper">
+    <select id="getTodayRules" resultType="com.xjrsoft.module.attendance.entity.AttendanceRuleDetails">
+        SELECT t2.* FROM attendance_rule_category t1
+        INNER JOIN attendance_rule_details t2 ON t1.id = t2.attendance_rule_category_id
+        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 AND NOW() BETWEEN start_date AND end_date
+        AND t2.date_type = #{dayOfWeek}
+    </select>
+
+</mapper>

+ 26 - 0
src/test/java/com/xjrsoft/module/job/AttendanceMessageTaskTest.java

@@ -0,0 +1,26 @@
+package com.xjrsoft.module.job;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.DayOfWeek;
+import java.time.LocalDateTime;
+import java.time.format.TextStyle;
+import java.util.Locale;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author dzx
+ * @date 2024/5/23
+ */
+class AttendanceMessageTaskTest {
+
+    @Test
+    void test(){
+        LocalDateTime now = LocalDateTime.now();
+        DayOfWeek dayOfWeek = now.getDayOfWeek();
+
+        String dayName = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.getDefault());
+        System.out.println("今天是:" + dayOfWeek.name());
+    }
+}

+ 3 - 3
src/test/java/com/xjrsoft/module/job/HikvisionBaseDataTaskTest.java

@@ -45,7 +45,9 @@ class HikvisionBaseDataTaskTest {
     @Autowired
     private FaceImportMapper faceImportMapper;
 
-    Teacher_Student_OutIn_RecordUtil teacherStudentOutInRecordUtil = new Teacher_Student_OutIn_RecordUtil();
+    @Autowired
+    EvaluateItemController evaluateItemController;
+
     @Test
     void test() throws Exception {
         DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
@@ -102,8 +104,6 @@ class HikvisionBaseDataTaskTest {
 //        String carTableName = "car_message_apply";
 //        selectCar(use, carTableName);
 
-        teacherStudentOutInRecordUtil.GetDoorEvents(use,faceImportMapper);
-
 
 //        selecAllPersonById(use);
         selectResource(use);