|
@@ -59,6 +59,8 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg refreshData(String month) {
|
|
|
+ //先删除当月的考勤记录
|
|
|
+ remove(new QueryWrapper<AttendanceStaff>().eq("month", month));
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
long l1 = System.currentTimeMillis();
|
|
|
this.remove(new QueryWrapper<AttendanceStaff>().eq("month", month));
|
|
@@ -147,23 +149,35 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
|
|
|
//加班申请
|
|
|
else if (applyForm.getType()==4){
|
|
|
- //一天都加班
|
|
|
- if (applyForm.getSumTime().compareTo(BigDecimal.valueOf(8))>=0){
|
|
|
- staff.setClockStartTime(LocalDateTime.of(date, LocalTime.of(8, 0)));
|
|
|
- staff.setClockEndTime(LocalDateTime.of(date, LocalTime.of(17, 0)));
|
|
|
- staff.setWorkHour(applyForm.getSumTime());//以加班申请的时长为准
|
|
|
- staff.setAttendanceType(JIA_BAN);
|
|
|
- staff.setAttendanceTypeName("加班");
|
|
|
+ //加班以实际打卡的时间和时长为准
|
|
|
+ List<Attendance> dayAttendance = attendances.stream().filter(a -> a.getClockTime().toLocalDate().equals(date)).collect(Collectors.toList());
|
|
|
+ if (jobNumber.equals("LEW3469") && date.equals(LocalDate.of(2025, 8, 9))) {
|
|
|
+ System.out.println("打卡数据====");
|
|
|
+ dayAttendance.forEach(System.out::println);
|
|
|
}
|
|
|
- //加班几个小时
|
|
|
- else if (applyForm.getSumTime().compareTo(BigDecimal.valueOf(8)) < 0 &&applyForm.getStartTime().equals(LocalDateTime.of(date, LocalTime.of(17, 0)))){
|
|
|
- staff.setClockStartTime(LocalDateTime.of(date, LocalTime.of(8, 0)));
|
|
|
- staff.setClockEndTime(applyForm.getEndTime());
|
|
|
- staff.setWorkHour(BigDecimal.valueOf(8).add(applyForm.getSumTime()));
|
|
|
- staff.setAttendanceType(JIA_BAN);
|
|
|
- staff.setAttendanceTypeName("加班");
|
|
|
+ if (dayAttendance.size() > 0) {
|
|
|
+ if (dayAttendance.size() == 1) {
|
|
|
+ staff.setClockStartTime(dayAttendance.get(0).getClockTime());
|
|
|
+ staff.setClockEndTime(dayAttendance.get(0).getClockTime().plusHours(8));
|
|
|
+ staff.setWorkHour(new BigDecimal(0));
|
|
|
+ staff.setAttendanceType(YI_CHANG);
|
|
|
+ staff.setAttendanceTypeName("班次异常");
|
|
|
+ } else {
|
|
|
+ //取上下班时间;按时间排序后取第一个和最后一个时间
|
|
|
+ attendances = attendances.stream()
|
|
|
+ .sorted(Comparator.comparing(Attendance::getClockTime))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ LocalDateTime startClockTime = dayAttendance.get(0).getClockTime();
|
|
|
+ LocalDateTime endClockTime = dayAttendance.get(dayAttendance.size() - 1).getClockTime();
|
|
|
+ staff.setClockStartTime(startClockTime);
|
|
|
+ staff.setClockEndTime(endClockTime);
|
|
|
+ BigDecimal bigDecimal = calculateWorkHours(startClockTime, endClockTime);
|
|
|
+ staff.setWorkHour(bigDecimal.compareTo(new BigDecimal(0)) > 0 ? bigDecimal : new BigDecimal(0));
|
|
|
+ staff.setAttendanceType(JIA_BAN);
|
|
|
+ staff.setAttendanceTypeName("加班");
|
|
|
+ }
|
|
|
+ addList.add(staff);
|
|
|
}
|
|
|
- addList.add(staff);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -568,6 +582,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
+ DateTimeFormatter hhMMFormatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
YearMonth yearMonth = YearMonth.parse(month, formatter);
|
|
|
// 3. 生成该月所有日期的信息
|
|
|
List<AttendanceStaff> allList = new ArrayList<>();
|
|
@@ -1171,6 +1186,14 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
maplist.add(map);
|
|
|
}
|
|
|
staff.setAttendanceTypeName("异常小夜班2");
|
|
|
+ } else if (type == JIA_BAN) {
|
|
|
+ //提取加班数据
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ String str = staff.getClockDate().format(formatter1) + " " + staff.getClockStartTime().format(hhMMFormatter)
|
|
|
+ + "-" + staff.getClockEndTime().format(hhMMFormatter) + ", 共" + staff.getWorkHour().toString() + "小时";
|
|
|
+ map.put("res", "加班");
|
|
|
+ map.put("msg", str);
|
|
|
+ maplist.add(map);
|
|
|
}
|
|
|
if (!maplist.isEmpty()) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
@@ -1184,7 +1207,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
.append(applyForm.getApplyBillName())
|
|
|
.append(" 时长")
|
|
|
.append(applyForm.getSumTime()).append("小时");
|
|
|
- }else if (applyForm.getType()!=6){
|
|
|
+ }else if (applyForm.getType()!=6 && applyForm.getType()!=4) {//加班要排除在外
|
|
|
stringBuilder
|
|
|
.append(applyForm.getStartTime().format(formatter2))
|
|
|
.append("-").append(applyForm.getEndTime().format(formatter2))
|
|
@@ -1196,6 +1219,9 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
}
|
|
|
if (!applyFormTypeList.isEmpty()){
|
|
|
for (ApplyForm applyForm : applyFormTypeList) {
|
|
|
+ if (applyForm.getType()==4) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (applyForm.getStartTime().toLocalDate().isEqual(clockDate)&&applyForm.getStartTime().toLocalTime().isAfter(LocalTime.of(4,0))) {
|
|
|
stringBuilder
|
|
|
.append(applyForm.getStartTime().format(formatter2))
|
|
@@ -1212,7 +1238,6 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
map.put("color","#F56C6C");
|
|
|
maplist.add(1,map);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else {
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
@@ -1391,7 +1416,7 @@ public class AttendanceStaffServiceImpl extends ServiceImpl<AttendanceStaffMappe
|
|
|
return holidays;
|
|
|
}
|
|
|
|
|
|
- public static BigDecimal calculateWorkHours(LocalDateTime start, LocalDateTime end) {
|
|
|
+ public BigDecimal calculateWorkHours(LocalDateTime start, LocalDateTime end) {
|
|
|
// 1. 计算时间差
|
|
|
Duration duration = Duration.between(start, end);
|
|
|
|