|
@@ -413,42 +413,43 @@ public class AttendanceSheetServiceImpl implements AttendanceSheetService {
|
|
|
}
|
|
|
} else {
|
|
|
//请假开始时间在早上下班之前,结束时间在早上下班之前,请假状态修改多天(1~n)全天考勤状态和结束日期当天早上考勤状态
|
|
|
- if (localTimeIsIn(startTime.toLocalTime(), normalTimePm, finishPmFlag) && localTimeIsIn(endTime.toLocalTime(), normalTimeAm, finishAmFlag)) {
|
|
|
+ if (localTimeIsIn(startTime.toLocalTime(), normalTimeAm, finishAmFlag) && localTimeIsIn(endTime.toLocalTime(), normalTimeAm, finishAmFlag)) {
|
|
|
LocalDateTime flagTime = startTime;
|
|
|
- while (LocalDateTimeUtil.isSameDay(flagTime, endTime)) {
|
|
|
+ while (!LocalDateTimeUtil.isSameDay(flagTime, endTime)) {
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_AM);
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_PM);
|
|
|
- flagTime = startTime.plusDays(1);
|
|
|
+ flagTime = flagTime.plusDays(1);
|
|
|
}
|
|
|
updateSheet(userId, attendanceStatus, endTime, ATTENDANCE_TYPE_AM);
|
|
|
}
|
|
|
//请假开始时间在早上下班之前,结束时间在下午下班之前,请假状态修改多天(1~n)全天考勤状态
|
|
|
- if (localTimeIsIn(startTime.toLocalTime(), normalTimePm, finishPmFlag) && localTimeIsIn(endTime.toLocalTime(), normalTimePm, finishPmFlag)) {
|
|
|
+ if (localTimeIsIn(startTime.toLocalTime(), normalTimeAm, finishAmFlag) && localTimeIsIn(endTime.toLocalTime(), normalTimePm, finishPmFlag)) {
|
|
|
LocalDateTime flagTime = startTime;
|
|
|
- while (LocalDateTimeUtil.isSameDay(flagTime, endTime)) {
|
|
|
+ while (!LocalDateTimeUtil.isSameDay(flagTime, endTime.plusDays(1))) {
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_AM);
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_PM);
|
|
|
- flagTime = startTime.plusDays(1);
|
|
|
+ flagTime = flagTime.plusDays(1);
|
|
|
}
|
|
|
}
|
|
|
//请假开始时间在下午下班之前,结束时间在下午下班之前,请假状态修改修改多天(1~n)全天考勤状态和起始日期当天下午考勤状态
|
|
|
if (localTimeIsIn(startTime.toLocalTime(), normalTimePm, finishPmFlag) && localTimeIsIn(endTime.toLocalTime(), normalTimePm, finishPmFlag)) {
|
|
|
- LocalDateTime flagTime = startTime;
|
|
|
- while (LocalDateTimeUtil.isSameDay(flagTime, endTime)) {
|
|
|
+ LocalDateTime flagTime = startTime.plusDays(1);
|
|
|
+ while (!LocalDateTimeUtil.isSameDay(flagTime, endTime.plusDays(1))) {
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_AM);
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_PM);
|
|
|
- flagTime = startTime.plusDays(1);
|
|
|
+ flagTime = flagTime.plusDays(1);
|
|
|
}
|
|
|
- updateSheet(userId, attendanceStatus, startTime, ATTENDANCE_TYPE_AM);
|
|
|
+ updateSheet(userId, attendanceStatus, startTime, ATTENDANCE_TYPE_PM);
|
|
|
}
|
|
|
//请假开始时间在下午下班之前,结束时间在早上下班之前,请假状态修改多天(0~n)全天考勤状态和结束日期当天早上考勤状态和起始日期当天下午考勤状态
|
|
|
if (localTimeIsIn(startTime.toLocalTime(), normalTimePm, finishPmFlag) && localTimeIsIn(endTime.toLocalTime(), normalTimeAm, finishAmFlag)) {
|
|
|
updateSheet(userId, attendanceStatus, startTime, ATTENDANCE_TYPE_PM);
|
|
|
+ updateSheet(userId, attendanceStatus, endTime, ATTENDANCE_TYPE_AM);
|
|
|
LocalDateTime flagTime = startTime.plusDays(1);
|
|
|
- while (LocalDateTimeUtil.isSameDay(flagTime, endTime)) {
|
|
|
+ while (!LocalDateTimeUtil.isSameDay(flagTime, endTime)) {
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_AM);
|
|
|
updateSheet(userId, attendanceStatus, flagTime, ATTENDANCE_TYPE_PM);
|
|
|
- flagTime = startTime.plusDays(1);
|
|
|
+ flagTime = flagTime.plusDays(1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -457,8 +458,23 @@ public class AttendanceSheetServiceImpl implements AttendanceSheetService {
|
|
|
|
|
|
private void updateSheet(String userId, Integer attendanceStatus, LocalDateTime endTime, Integer attendanceType) {
|
|
|
AttendanceSheetDO sheetDO = attendanceSheetMapper.selectOne(LocalDateTimeUtils.buildTime(endTime.getYear(), endTime.getMonthValue(), endTime.getDayOfMonth()), attendanceType, userId);
|
|
|
- sheetDO.setAttendanceStatus(attendanceStatus).setAttendanceSource(1);
|
|
|
- attendanceSheetMapper.updateById(sheetDO);
|
|
|
+ if(sheetDO!=null){
|
|
|
+ sheetDO.setAttendanceStatus(attendanceStatus).setAttendanceSource(1);
|
|
|
+ attendanceSheetMapper.updateById(sheetDO);
|
|
|
+ }else {
|
|
|
+ AdminUserRespDTO adminUserRespDTO = userApi.getUser(userId).getCheckedData();
|
|
|
+ AttendanceSheetDO newSheetDO = new AttendanceSheetDO()
|
|
|
+ .setAttendanceSource(1)
|
|
|
+ .setAttendanceType(attendanceType)
|
|
|
+ .setAttendanceStatus(attendanceStatus)
|
|
|
+ .setAttendanceDate(LocalDateTimeUtils.buildTime(endTime.getYear(), endTime.getMonthValue(), endTime.getDayOfMonth()))
|
|
|
+ .setDeptId(adminUserRespDTO.getDeptId())
|
|
|
+ .setUserId(adminUserRespDTO.getId())
|
|
|
+ .setNickname(adminUserRespDTO.getNickname())
|
|
|
+ .setUsername(adminUserRespDTO.getUsername());
|
|
|
+ attendanceSheetMapper.insert(newSheetDO);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|