From 5db13c2ad6678cf4614b81c95df035c6f47d313d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 16 十月 2026 21:57:36 +0800
Subject: [PATCH] feat(hrm): 考勤规则放开部门唯一限制,支持同一部门多班次
---
yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceRecordServiceImpl.java | 55 +++++++++++++++++++++++++++++++------------------------
1 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceRecordServiceImpl.java b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceRecordServiceImpl.java
index 60ba60d..2fa76d3 100644
--- a/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceRecordServiceImpl.java
+++ b/yudao-module-hrm/src/main/java/cn/iocoder/yudao/module/hrm/service/attendance/HrmAttendanceRecordServiceImpl.java
@@ -88,27 +88,31 @@
if (record.getDeptId() == null) {
return;
}
- HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(record.getDeptId());
- if (rule == null) {
- return;
+ // 涓婄彮鎵撳崱绫诲瀷锛氭櫄浜� 涓婄彮鏃堕棿+杩熷埌鍏佽 璁颁负杩熷埌锛堟寜涓婄彮鎵撳崱鏃堕棿鍖归厤鐝锛�
+ if (record.getClockInTime() != null) {
+ HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(
+ record.getDeptId(), record.getClockInTime());
+ if (rule != null && rule.getWorkStartTime() != null) {
+ int lateAllowMinutes = rule.getLateAllowMinutes() != null ? rule.getLateAllowMinutes() : 0;
+ LocalTime lateThreshold = rule.getWorkStartTime().plusMinutes(lateAllowMinutes);
+ LocalTime clockInOnly = record.getClockInTime().toLocalTime();
+ record.setClockInType(clockInOnly.isAfter(lateThreshold)
+ ? HrmAttendanceClockTypeEnum.LATE.getType()
+ : HrmAttendanceClockTypeEnum.NORMAL.getType());
+ }
}
- // 涓婄彮鎵撳崱绫诲瀷锛氭櫄浜� 涓婄彮鏃堕棿+杩熷埌鍏佽 璁颁负杩熷埌
- if (record.getClockInTime() != null && rule.getWorkStartTime() != null) {
- int lateAllowMinutes = rule.getLateAllowMinutes() != null ? rule.getLateAllowMinutes() : 0;
- LocalTime lateThreshold = rule.getWorkStartTime().plusMinutes(lateAllowMinutes);
- LocalTime clockInOnly = record.getClockInTime().toLocalTime();
- record.setClockInType(clockInOnly.isAfter(lateThreshold)
- ? HrmAttendanceClockTypeEnum.LATE.getType()
- : HrmAttendanceClockTypeEnum.NORMAL.getType());
- }
- // 涓嬬彮鎵撳崱绫诲瀷锛氭棭浜� 涓嬬彮鏃堕棿-鏃╅��鍏佽 璁颁负鏃╅��
- if (record.getClockOutTime() != null && rule.getWorkEndTime() != null) {
- int earlyAllowMinutes = rule.getEarlyAllowMinutes() != null ? rule.getEarlyAllowMinutes() : 0;
- LocalTime earlyThreshold = rule.getWorkEndTime().minusMinutes(earlyAllowMinutes);
- LocalTime clockOutOnly = record.getClockOutTime().toLocalTime();
- record.setClockOutType(clockOutOnly.isBefore(earlyThreshold)
- ? HrmAttendanceClockTypeEnum.EARLY.getType()
- : HrmAttendanceClockTypeEnum.NORMAL.getType());
+ // 涓嬬彮鎵撳崱绫诲瀷锛氭棭浜� 涓嬬彮鏃堕棿-鏃╅��鍏佽 璁颁负鏃╅��锛堟寜涓嬬彮鎵撳崱鏃堕棿鍖归厤鐝锛�
+ if (record.getClockOutTime() != null) {
+ HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(
+ record.getDeptId(), record.getClockOutTime());
+ if (rule != null && rule.getWorkEndTime() != null) {
+ int earlyAllowMinutes = rule.getEarlyAllowMinutes() != null ? rule.getEarlyAllowMinutes() : 0;
+ LocalTime earlyThreshold = rule.getWorkEndTime().minusMinutes(earlyAllowMinutes);
+ LocalTime clockOutOnly = record.getClockOutTime().toLocalTime();
+ record.setClockOutType(clockOutOnly.isBefore(earlyThreshold)
+ ? HrmAttendanceClockTypeEnum.EARLY.getType()
+ : HrmAttendanceClockTypeEnum.NORMAL.getType());
+ }
}
}
@@ -123,9 +127,10 @@
.divide(BigDecimal.valueOf(60), 2, RoundingMode.HALF_UP);
record.setWorkHours(workHours);
}
- // 鍔犵彮鏃堕暱锛氭寜鑰冨嫟瑙勫垯鐨勬爣鍑嗕笅鐝椂闂磋绠楄秴棰濋儴鍒�
+ // 鍔犵彮鏃堕暱锛氭寜鑰冨嫟瑙勫垯鐨勬爣鍑嗕笅鐝椂闂磋绠楄秴棰濋儴鍒嗭紙鎸変笅鐝墦鍗℃椂闂村尮閰嶇彮娆★級
if (record.getClockOutTime() != null && record.getDeptId() != null) {
- HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(record.getDeptId());
+ HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(
+ record.getDeptId(), record.getClockOutTime());
if (rule != null && rule.getWorkEndTime() != null) {
LocalTime workEnd = rule.getWorkEndTime();
LocalDate outDate = record.getClockOutTime().toLocalDate();
@@ -159,7 +164,8 @@
if (employee == null) {
throw exception(EMPLOYEE_NOT_EXISTS);
}
- HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(employee.getDeptId());
+ // 鎸夋湰娆℃墦鍗℃椂闂村尮閰嶇彮娆★紙鍚屼竴涓儴闂ㄥ彲鑳介厤缃簡澶氭潯瑙勫垯锛�
+ HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(employee.getDeptId(), clockTime);
if (rule == null) {
throw exception(ATTENDANCE_CLOCK_FAIL_NO_RULE);
}
@@ -212,7 +218,8 @@
if (employee == null) {
throw exception(EMPLOYEE_NOT_EXISTS);
}
- HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(employee.getDeptId());
+ // 鎸夋湰娆℃墦鍗℃椂闂村尮閰嶇彮娆★紙鍚屼竴涓儴闂ㄥ彲鑳介厤缃簡澶氭潯瑙勫垯锛�
+ HrmAttendanceRuleDO rule = attendanceRuleService.getAttendanceRuleByDeptId(employee.getDeptId(), clockTime);
if (rule == null) {
throw exception(ATTENDANCE_CLOCK_FAIL_NO_RULE);
}
--
Gitblit v1.9.3