From dd8e45b4405debe795e27c3dccd2fabda6536bb5 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Wed, 06 Aug 2025 02:26:46 +0000
Subject: [PATCH] 添加单日最大出差时长限制
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java | 44 ++++++++++++++++++++++++++++++--------------
1 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
index e8806f2..40a3c28 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
@@ -233,6 +233,12 @@
for (User user : userList) {
// 考勤记录:根据用户和日期查询
Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), startAttendDate);
+ // TODO:20250801修改 当天新建用户没有经过0点的考勤信息创建会空指针,需要创建记录
+ if (attendance == null || attendance.getId().equals(null)) {
+ getWeComAttendanceList(Timestamp.valueOf(startAttendDate + " 00:00:00"), Arrays.asList(user));
+ attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), startAttendDate);
+ }
+
Boolean isHoliday = false;
if (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) {
isHoliday = true;
@@ -372,6 +378,12 @@
for (User user : userList) {
// 考勤记录:根据用户和日期查询
Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), startAttendDate);
+ // TODO:20250801修改 当天新建用户没有经过0点的考勤信息创建会空指针,需要创建记录
+ if (attendance == null || attendance.getId().equals(null)) {
+ getWeComAttendanceList(Timestamp.valueOf(startAttendDate + " 00:00:00"), Arrays.asList(user));
+ attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(user.getId(), startAttendDate);
+ }
+
Boolean isHoliday = false;
if (calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calAttendDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || attendance.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS) || attendance.getDateType().equals(Constant.DATE_TYPE_WEEKEND)) {
isHoliday = true;
@@ -752,16 +764,16 @@
} else {
// 上午
if (day) {
- // 上午时长 >= 上午排班时间 改打卡状态 否则 缺时
- if (duration >= result) {
+ // 上午时长 >= 上午排班时间 改打卡状态 否则 缺时 TODO:20250805修改 排除休息日情况
+ if (duration >= result || attendance.getStartLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setStartClockResults(type);
attendance.setStartLocationResults(null);
} else {
attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME);
}
} else {
- // 下午时长 >= 下午排班时间 改打卡状态 否则 缺时
- if (duration >= noonResult) {
+ // 下午时长 >= 下午排班时间 改打卡状态 否则 缺时 TODO:20250805修改 排除休息日情况
+ if (duration >= noonResult || attendance.getEndLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setEndClockResults(type);
attendance.setEndLocationResults(null);
} else {
@@ -783,14 +795,16 @@
} else {
//打卡的情况,修改考勤状态
if (day) {
- if ((duration + result1) >= result) {
+ // TODO:20250805修改 排除休息日情况
+ if ((duration + result1) >= result || attendance.getStartLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setStartClockResults(type);
attendance.setStartLocationResults(null);
} else {
attendance.setStartClockResults(Constant.ATTENDANCE_STATE_LACK_OF_TIME);
}
} else {
- if ((duration + noonResult1) >= noonResult) {
+ // TODO:20250805修改 排除休息日情况
+ if ((duration + noonResult1) >= noonResult || attendance.getEndLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setEndClockResults(type);
attendance.setEndLocationResults(null);
} else {
@@ -862,9 +876,9 @@
*/
public Boolean getCardSupplement(Long userId, String st, Timestamp checkTime) {
if (ObjectUtils.isNotEmpty(checkTime)) {
- // 查询补卡记录
+ // 查询补卡记录 TODO:20250805修改 正常考勤状态全部验证通过处理
AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findByUserIdAndTime(userId, checkTime);
- if (ObjectUtils.isNotEmpty(attendanceCardreplacement) && st.equals(Constant.ATTENDANCE_STATE_NORMAL)) {
+ if (ObjectUtils.isNotEmpty(attendanceCardreplacement) && (st.equals(Constant.ATTENDANCE_STATE_NORMAL) || st.equals(Constant.ATTENDANCE_STATE_LEAVE) || st.equals(Constant.ATTENDANCE_STATE_BUSINESS)|| st.equals(Constant.ATTENDANCE_STATE_GOOUT))) {
return true;
}
}
@@ -909,8 +923,8 @@
*/
public void setAttendance(Double sDuration, Double eDuration, Double result, Double noonResult, Attendance attendance, String type) {
if (ObjectUtils.isEmpty(eDuration) && ObjectUtils.isEmpty(noonResult)) {
- // 上午时长 >= 上午排班时间 改打卡状态 否则 缺时
- if (sDuration >= result) {
+ // 上午时长 >= 上午排班时间 改打卡状态 否则 缺时 TODO:20250805修改 排除休息日情况
+ if (sDuration >= result || attendance.getStartLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setStartClockResults(type);
attendance.setStartLocationResults(null);
} else {
@@ -918,8 +932,8 @@
}
}
if (ObjectUtils.isEmpty(sDuration) && ObjectUtils.isEmpty(result)) {
- // 下午时长 >= 下午排班时间 改打卡状态 否则 缺时
- if (eDuration >= noonResult) {
+ // 下午时长 >= 下午排班时间 改打卡状态 否则 缺时 TODO:20250805修改 排除休息日情况
+ if (eDuration >= noonResult || attendance.getEndLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setEndClockResults(type);
attendance.setEndLocationResults(null);
} else {
@@ -940,7 +954,8 @@
*/
public void setAttendanceStart(Double sDuration, Double eDuration, Double result1, Double result, Double noonResult, Attendance attendance, String type) {
if (ObjectUtils.isEmpty(eDuration) && sDuration > 0) {
- if ((sDuration + result1) >= result) {
+ // TODO:20250805修改 排除休息日情况
+ if ((sDuration + result1) >= result || attendance.getStartLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setStartClockResults(type);
attendance.setStartLocationResults(null);
} else {
@@ -948,7 +963,8 @@
}
}
if (ObjectUtils.isEmpty(sDuration) && eDuration > 0) {
- if ((eDuration + result1) >= noonResult) {
+ // TODO:20250805修改 排除休息日情况
+ if ((eDuration + result1) >= noonResult || attendance.getEndLocationResults().equals(Constant.LOCATION_RESULTS_REST)) {
attendance.setEndClockResults(type);
attendance.setEndLocationResults(null);
} else {
--
Gitblit v1.9.3