Ver Fonte

Merge branch 'pre'

dzx há 1 ano atrás
pai
commit
9f016c197d

+ 2 - 0
src/main/java/com/xjrsoft/module/attendance/controller/StudentStatisticsController.java

@@ -13,6 +13,7 @@ import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
 import com.xjrsoft.module.attendance.dto.StudentDetailsDto;
+import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
 import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.attendance.vo.StudentStatisticsPageVo;
 import com.xjrsoft.module.base.entity.BaseClass;
@@ -68,6 +69,7 @@ public class StudentStatisticsController {
     private final IStudentLeaveService studentLeaveService;
     private final IBaseClassService classService;
     private final IHolidayDateService holidayDateService;
+    private final IAttendanceRuleCategoryService ruleCategoryService;
 
     @GetMapping(value = "/class-statistics")
     @ApiOperation(value="班级考勤统计")

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

@@ -6,7 +6,9 @@ import com.xjrsoft.module.attendance.dto.UpdateAttendanceRuleCategoryDto;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleCategory;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
 import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
+import com.xjrsoft.module.attendance.vo.TimeRangeVo;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
 
@@ -57,4 +59,6 @@ public interface IAttendanceRuleCategoryService extends MPJBaseService<Attendanc
 
     Map<Long, AttendanceRuleDetailsUserVo> getTeacherTodyRuleByUserId(List<Long> teacherIds);
 
+    List<TimeRangeVo> getAllTimeRange(LocalDateTime startTime, LocalDateTime endTime);
+
 }

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

@@ -20,6 +20,7 @@ import com.xjrsoft.module.attendance.mapper.AttendanceRuleDetailsMapper;
 import com.xjrsoft.module.attendance.mapper.AttendanceUserRelationMapper;
 import com.xjrsoft.module.attendance.service.IAttendanceRuleCategoryService;
 import com.xjrsoft.module.attendance.vo.AttendanceRuleDetailsUserVo;
+import com.xjrsoft.module.attendance.vo.TimeRangeVo;
 import com.xjrsoft.module.concat.service.IXjrUserService;
 import com.xjrsoft.module.organization.entity.UserDeptRelation;
 import com.xjrsoft.module.student.entity.BaseStudent;
@@ -33,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.DayOfWeek;
 import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -493,4 +495,23 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
         }
         return dataMap;
     }
+
+    @Override
+    public List<TimeRangeVo> getAllTimeRange(LocalDateTime startTime, LocalDateTime endTime) {
+        long between = ChronoUnit.DAYS.between(startTime, endTime);
+        List<String> dayOfWeeks = new ArrayList<>();
+        Map<String, LocalDateTime> timeMap = new HashMap<>();
+        for (int i = 0; i <= between; i ++) {
+            String name = startTime.plusDays(i).getDayOfWeek().name();
+            dayOfWeeks.add(name);
+            timeMap.put(name, startTime.plusDays(i));
+        }
+
+        List<AttendanceRuleDetails> detailsList = detailsMapper.selectList(
+                new QueryWrapper<AttendanceRuleDetails>().lambda()
+                        .in(AttendanceRuleDetails::getDateType, dayOfWeeks)
+        );
+
+        return null;
+    }
 }

+ 26 - 0
src/main/java/com/xjrsoft/module/attendance/vo/TimeRangeVo.java

@@ -0,0 +1,26 @@
+package com.xjrsoft.module.attendance.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+/**
+* @title: 考勤时间段
+* @Author dzx
+* @Date: 2024年6月17日
+* @Version 1.0
+*/
+@Data
+public class TimeRangeVo {
+
+    @ApiModelProperty("开始时间")
+    private LocalDateTime startTime;
+
+    @ApiModelProperty("结束时间")
+    private LocalDateTime endTime;
+
+    @ApiModelProperty("时段(1=上午 2=下午 3=晚上)")
+    private Integer timePeriod;
+
+}

+ 3 - 0
src/main/java/com/xjrsoft/module/concat/controller/ConcatController.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.concat.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.DeleteMark;
@@ -64,6 +65,8 @@ public class ConcatController {
                 .leftJoin("xjr_user_role_relation t3 ON t.id = t3.user_id")
                 .leftJoin("xjr_role t4 ON t4.id = t3.role_id")
                 .eq("t4.id", 2)
+                .eq(StrUtil.isNotEmpty(dto.getName()), XjrUser::getName, dto.getName())
+                .eq(StrUtil.isNotEmpty(dto.getMobile()), XjrUser::getMobile, dto.getMobile())
                 .eq(XjrUser::getDeleteMark, DeleteMark.NODELETE.getCode());
         List<XjrUser> userList = xjrUserService.selectJoinList(XjrUser.class, wrapper);
         for (XjrUser user : userList) {

+ 4 - 5
src/main/java/com/xjrsoft/module/hikvision/controller/EventController.java

@@ -31,7 +31,6 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.sql.SQLException;
 import java.text.ParseException;
 import java.util.List;
 import java.util.Objects;
@@ -58,8 +57,8 @@ public class EventController {
         new Thread(() -> {
             try {
                 outInRecordUtil.GetVehicleRecordTest(faceImportMapper, eventData);
-            } catch (SQLException | ParseException e) {
-                log.error("Error processing event data", e);
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
             }
         }).start();
 
@@ -140,7 +139,7 @@ public class EventController {
                         weChatService.sendTemplateMessage(weChatSendMessageDto);
                     }
                 }
-            } catch (SQLException | ParseException e) {
+            } catch (ParseException e) {
                 log.error("Error processing event data", e);
             }
         }).start();
@@ -155,7 +154,7 @@ public class EventController {
         new Thread(() -> {
             try {
                 outInRecordUtil.GetVisitRecordsTest(faceImportMapper, eventData);
-            } catch (SQLException | ParseException e) {
+            } catch (ParseException e) {
                 log.error("Error processing event data", e);
             }
         }).start();

+ 25 - 28
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -12,7 +12,6 @@ import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.SQLException;
 import java.sql.Types;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -28,7 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class OutInRecordUtil {
     private static final Logger log = LoggerFactory.getLogger(OutInRecordUtil.class);
 
-    private void teacherInsertRecord(Long userId, String recordTime, String facePhoto, int status, String eventId, String attendanceStatus) throws SQLException {
+    private void teacherInsertRecord(Long userId, String recordTime, String facePhoto, int status, String eventId, String attendanceStatus){
         String photoValue = (facePhoto != null && !facePhoto.equals("null")) ? facePhoto : "";
 
         String sql = "INSERT INTO teacher_out_in_record(create_date, user_id, record_time, face_photo, eventId, status,delete_mark,enabled_mark, attendance_status) " +
@@ -37,7 +36,7 @@ public class OutInRecordUtil {
         SqlRunnerAdapter.db().insert(sql);
     }
 
-    private void studentInsertRecord(Long userId, Long teacherId, Long classId, String facePhoto, String recordTime, int status, String eventId, String attendanceStatus) throws SQLException {
+    private void studentInsertRecord(Long userId, Long teacherId, Long classId, String facePhoto, String recordTime, int status, String eventId, String attendanceStatus){
         String photoValue = (facePhoto != null && !facePhoto.equals("null")) ? facePhoto : "";
 
         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, attendance_status) " +
@@ -47,7 +46,7 @@ public class OutInRecordUtil {
     }
 
 
-    public void visitInsertRecord(Long reservation_school_people_id, String recordTime,String facePhoto, String status, String eventId) throws SQLException {
+    public void visitInsertRecord(Long reservation_school_people_id, String recordTime,String facePhoto, String status, String eventId){
         String sql = "INSERT INTO visitor_out_in_record(create_date, reservation_school_people_id, record_time, face_photo, event_id, status,delete_mark,enabled_mark) " +
                 "VALUES(now(), '"  + reservation_school_people_id + "', '" +
                  recordTime + "', '" + facePhoto + "', '" + eventId + "', '" + status +  "',0,1)";
@@ -55,7 +54,7 @@ public class OutInRecordUtil {
     }
 
     private void vehicleInsertRecord(Long carMessageApplyId, String recordTime, int releaseReason, int category, String facePhoto, int status, String planNo, String crossRecordSyscode,
-                                     int releaseResult, int releaseWay, int vehicleType, String phone, String name) throws SQLException {
+                                     int releaseResult, int releaseWay, int vehicleType, String phone, String name){
         String phoneValue = (phone != null && !phone.equals("null")) ? phone : "";
         String nameValue = (name != null && !name.equals("null")) ? name : "";
         String photoValue = (facePhoto != null && !facePhoto.equals("null")) ? facePhoto : "";
@@ -83,7 +82,7 @@ public class OutInRecordUtil {
 
     }
 
-    public void GetTeacherAndStudentRecords(FaceImportMapper faceImportMapper) throws SQLException, ParseException {
+    public void GetTeacherAndStudentRecords(FaceImportMapper faceImportMapper) throws ParseException {
         JsonArray responseBuilder = new JsonArray();
 
         AtomicInteger pageNo = new AtomicInteger(1);
@@ -108,7 +107,7 @@ public class OutInRecordUtil {
         InsertTeacherStudentRecords(responseBuilder, faceImportMapper);
     }
 
-    private void InsertTeacherStudentRecords(JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
+    private void InsertTeacherStudentRecords(JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws ParseException {
         List<String> teacherEventIdList = faceImportMapper.GetTeacherUrlList();
         List<String> studentEventIdList = faceImportMapper.GetStudentUrlList();
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -123,16 +122,16 @@ public class OutInRecordUtil {
             }
             if (personId == null) continue;
 
-            int status = item.get("inAndOutType").getAsInt();
-//            int status = -1;
-//            switch (statusInt){
-//                case 0:
-//                    status = 1;
-//                    break;
-//                case 1:
-//                    status = 0;
-//                    break;
-//            }
+            int statusInt = item.get("inAndOutType").getAsInt();
+            int status = -1;
+            switch (statusInt){
+                case 0:
+                    status = 1;
+                    break;
+                case 1:
+                    status = 0;
+                    break;
+            }
 
             String uri = item.get("picUri").isJsonNull() ? null : item.get("picUri").getAsString();
             String recordTime = item.get("eventTime").isJsonNull() ? null : item.get("eventTime").getAsString();
@@ -159,7 +158,7 @@ public class OutInRecordUtil {
         }
     }
 
-    String discernTeacherStatus(LocalDateTime recordTime, int status, Long userId) throws SQLException {
+    String discernTeacherStatus(LocalDateTime recordTime, int status, Long userId){
         String attendanceStatus = "";
         String dayOfWeek = recordTime.getDayOfWeek().name();
         String sql = "SELECT t2.* FROM attendance_rule_category t1" +
@@ -214,7 +213,7 @@ public class OutInRecordUtil {
         return attendanceStatus;
     }
 
-    String discernStudentStatus(LocalDateTime recordTime, int status, Long studentUserId) throws SQLException {
+    String discernStudentStatus(LocalDateTime recordTime, int status, Long studentUserId){
         String attendanceStatus = "";
         String dayOfWeek = recordTime.getDayOfWeek().name();
         String sql = "SELECT t2.* FROM attendance_rule_category t1" +
@@ -288,7 +287,7 @@ public class OutInRecordUtil {
         return attendanceStatus;
     }
 
-    public void GetVisitRecord(FaceImportMapper faceImportMapper) throws SQLException, ParseException {
+    public void GetVisitRecord(FaceImportMapper faceImportMapper) throws ParseException {
         ApiUtil apiUtil = new ApiUtil();
 
         AtomicInteger pageNo = new AtomicInteger(1);
@@ -329,7 +328,7 @@ public class OutInRecordUtil {
         InsertVisitRecords(responseBuilder,responseDoorBuilder,faceImportMapper);
     }
 
-    private void InsertVisitRecords(JsonArray eventsResponse, JsonArray doorEventsResponse,FaceImportMapper faceImportMapper) throws SQLException, ParseException {
+    private void InsertVisitRecords(JsonArray eventsResponse, JsonArray doorEventsResponse,FaceImportMapper faceImportMapper) throws ParseException {
 
         for (JsonElement element : eventsResponse) {
             List<String> visit_id_list = faceImportMapper.GetReservationSchoolIdList();
@@ -358,7 +357,7 @@ public class OutInRecordUtil {
 
     }
 
-    public void GetVehicleRecord(FaceImportMapper faceImportMapper) throws SQLException, ParseException {
+    public void GetVehicleRecord(FaceImportMapper faceImportMapper) throws ParseException {
         ApiUtil apiUtil = new ApiUtil();
 
         AtomicInteger pageNo = new AtomicInteger(1);
@@ -389,7 +388,7 @@ public class OutInRecordUtil {
         InsertVehicleRecords(responseBuilder,faceImportMapper);
     }
 
-    private void InsertVehicleRecords(JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
+    private void InsertVehicleRecords(JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws ParseException {
         List<String> vehicle_id_list = faceImportMapper.GetVehicleIdList();
 
         for (JsonElement element : doorEventsResponse) {
@@ -466,8 +465,6 @@ public class OutInRecordUtil {
         JsonObject paramJson = new JsonObject();
         paramJson.addProperty("pageNo", pageNo.get());
         paramJson.addProperty("pageSize", pageSize);
-        paramJson.addProperty("startTime", "2024-06-01T00:00:00Z");
-        paramJson.addProperty("endTime", "2024-06-12T00:00:00Z");
 
         return apiUtil.doPost(apiPath, String.valueOf(paramJson), null);
     }
@@ -479,7 +476,7 @@ public class OutInRecordUtil {
         return mysqlFormat.format(date);
     }
 
-    public void GetTeacherAndStudentRecordsTest(FaceImportMapper faceImportMapper, JsonObject data) throws SQLException, ParseException {
+    public void GetTeacherAndStudentRecordsTest(FaceImportMapper faceImportMapper, JsonObject data) throws ParseException {
         try {
             List<String> teacherEventIdList = faceImportMapper.GetTeacherUrlList();
             List<String> studentEventIdList = faceImportMapper.GetStudentUrlList();
@@ -541,7 +538,7 @@ public class OutInRecordUtil {
     }
 
 
-    public void GetVehicleRecordTest(FaceImportMapper faceImportMapper, String data) throws SQLException, ParseException {
+    public void GetVehicleRecordTest(FaceImportMapper faceImportMapper, String data) throws ParseException {
         if (data != null) {
             List<String> vehicle_id_list = faceImportMapper.GetVehicleIdList();
             try {
@@ -613,7 +610,7 @@ public class OutInRecordUtil {
         }
     }
 
-    public void GetVisitRecordsTest(FaceImportMapper faceImportMapper, String data) throws SQLException, ParseException {
+    public void GetVisitRecordsTest(FaceImportMapper faceImportMapper, String data) throws ParseException {
         if (data != null) {
             List<String> visit_id_list = faceImportMapper.GetVisitIdList();
 

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

@@ -107,6 +107,12 @@ public class AttendanceMessageTask {
         List<AttendanceRuleDetails> ruleDetails = ruleCategoryService.getTodayRules();
         //获取最近的时间
         LocalDateTime recentlyTime = getRecentlyTime(ruleDetails, now);
+        if(now.isBefore(recentlyTime)){
+            log.info("未到时间,不需要提醒");
+            return;
+        }
+
+
         String wechatTemplate = weChatUtil.getAttendanceMessageTemplate();
         WechatMessageLog log = wechatMessageLogService.getOne(
                 new QueryWrapper<WechatMessageLog>().lambda()
@@ -174,6 +180,8 @@ public class AttendanceMessageTask {
                         new MPJLambdaWrapper<TeacherOutInRecord>()
                                 .le(TeacherOutInRecord::getRecordTime, recentlyTime)
                                 .eq(TeacherOutInRecord::getStatus, 1)
+                                .eq("DATE_FORMAT(record_time, '%Y-%m-%d')" , recentlyTime.toLocalDate())
+                                .groupBy(TeacherOutInRecord::getUserId)
                 );
 
                 WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();

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

@@ -80,7 +80,6 @@ public class StudentOutInRecordController {
                 .leftJoin(BaseClass.class,BaseClass::getId,StudentOutInRecord::getClassId,ext->ext.selectAs(BaseClass::getName,StudentOutInRecordPageVo::getClassCn))
                 .leftJoin(XjrUser.class,XjrUser::getId,StudentOutInRecord::getTeacherId,ext->ext.selectAs(XjrUser::getName,StudentOutInRecordPageVo::getTeacherCn))
                 .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))
                 ;
 

+ 1 - 1
src/main/java/com/xjrsoft/module/student/controller/ConsumptionController.java

@@ -160,7 +160,7 @@ public class ConsumptionController {
     @GetMapping(value = "/fee-detail")
     @ApiOperation(value="学生缴费的详情")
     @SaCheckPermission("consumption:detail")
-    public RT<List<FeeDetailListVo>> feeDetail(@RequestParam String studentcode, @RequestParam String beltcode){
+    public RT<List<FeeDetailListVo>> feeDetail(@RequestParam String studentcode, String beltcode){
         return RT.ok(pbVXsxxsfytbService.getFeeDetail(studentcode, beltcode));
     }
 

+ 11 - 0
src/main/java/com/xjrsoft/module/system/controller/LoginController.java

@@ -290,4 +290,15 @@ public class LoginController {
         String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
         return R.ok(authorizeUrl);
     }
+
+    @GetMapping("/imgcaptcha-answer")
+    @ApiOperation(value = "图形验证码", notes = "图形验证码")
+    public R imgcaptchaAnswer(String key) {
+        String active = SpringUtil.getActiveProfile();
+        if(!"dev".equals(active)){
+            return R.ok();
+        }
+
+        return R.ok(redisUtil.get(key));
+    }
 }

+ 1 - 0
src/main/resources/application-dev.yml

@@ -115,6 +115,7 @@ xjrsoft:
       - /event/receiveCar
       - /event/visit
       - /system/findUserByCode
+      - /system/imgcaptcha-answer
     approval-time: 300 # 审核超时时间 目前设为5分钟
   email:
     host:  #邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环境 dev|pre|prod
   profiles:
-    active: dev
+    active: prod
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 12 - 1
src/test/java/com/xjrsoft/module/job/AttendanceMessageTaskTest.java

@@ -86,7 +86,18 @@ class AttendanceMessageTaskTest {
     @Autowired
     private IWechatMessageLogService wechatMessageLogService;
 
-
+    @Test
+    void test3(){
+        LocalDateTime recentlyTime = LocalDateTime.now().withHour(8).withMinute(5).withSecond(0).withNano(0);
+        long outInRecords = teachertOutInRecordService.count(
+                new MPJLambdaWrapper<TeacherOutInRecord>()
+                        .le(TeacherOutInRecord::getRecordTime, recentlyTime)
+                        .eq(TeacherOutInRecord::getStatus, 1)
+                        .eq(true,"DATE_FORMAT(record_time, '%Y-%m-%d')" , recentlyTime.toLocalDate())
+                        .groupBy(TeacherOutInRecord::getUserId)
+        );
+        System.out.println(outInRecords);
+    }
     @Test
     void test2(){
         String  wechatTemplate = "o-KboOcqcJ3YpjPN2xwgM_NcjN-0yzwWlDDXYfTM0Q4";

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

@@ -83,8 +83,8 @@ class HikvisionBaseDataTaskTest {
 
     @Test
     void test() throws Exception {
-//        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
-//        Db use = Db.use(datasource);
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        Db use = Db.use(datasource);
 //        String sql = "SELECT distinct table_name FROM hikvision_data WHERE 1 = 1";
 //        List<JianyueData> query = use.query(sql, JianyueData.class);
 //        Set<String> tables = new HashSet<>();
@@ -138,7 +138,7 @@ class HikvisionBaseDataTaskTest {
 //        selectCar(use, carTableName);
 
 //        outInRecordUtil.GetVehicleRecord(use,faceImportMapper);
-//        outInRecordUtil.GetTeacherAndStudentRecords(use,faceImportMapper);
+        outInRecordUtil.GetTeacherAndStudentRecords(use,faceImportMapper);
 ////        selecAllPersonById(use);
 //        selectResource(use);
     }