zouyu
3 天以前 2ea3b36a810adcb639f4d3c72c860f722f601927
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/StaffAttendanceTrackingRecordServiceImpl.java
@@ -36,6 +36,7 @@
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -170,6 +171,8 @@
                 * 正常:当前班次结束后第一次出门时间
                 * 异常(早退):无当前班次结束到下一班次开始前的出门记录并且最后一次出门在当前班次时间范围内,取当前班次最后一次出门时间
                 */
                //当前时间
                LocalDateTime now  = LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
                // 当前班次开始天0点时间
                LocalDateTime startDateTime = LocalDateTime.of(p.getWorkTime().toLocalDate(), LocalTime.MIN);
                // 当前班次结束天24点时间
@@ -224,7 +227,7 @@
                                    && s.getSwingTime().isBefore(nextShiftStartDateTime))
                            .min(Comparator.comparing(StaffAttendanceTrackingRecord::getSwingTime))
                            .orElse(new StaffAttendanceTrackingRecord());
                    if (BeanUtil.isEmpty(exitRecord)) {
                    if (BeanUtil.isEmpty(exitRecord) && !now.isBefore(currentShiftEndDateTime)) {
                        exitRecord = exitRecords.stream()
                                .filter(s -> (s.getSwingTime().isAfter(currentShiftStartDateTime)
                                        && s.getSwingTime().isBefore(currentShiftEndDateTime)))
@@ -258,9 +261,13 @@
                vo.setCreateTime(recordList.get(0).getCreateTime());
                vo.setUpdateUser(recordList.get(0).getUpdateUser());
                vo.setUpdateTime(recordList.get(0).getUpdateTime());
                vo.setResult(ClockInState.ABNORMAL.getValue());
                if(ObjectUtils.allNotNull(vo.getWorkClockInState(),vo.getOffClockInState())){
                    vo.setResult(Integer.min(vo.getWorkClockInState(),vo.getOffClockInState()));
                //当前时间在下班时间过后才判断考勤结果
                if(!now.isBefore(currentShiftEndDateTime)){
                    if(ObjectUtils.allNotNull(vo.getWorkClockInState(),vo.getOffClockInState())){
                        vo.setResult(Integer.min(vo.getWorkClockInState(),vo.getOffClockInState()));
                    }else{
                        vo.setResult(ClockInState.ABNORMAL.getValue());
                    }
                }
                // 计算缺勤时长
                if (ObjectUtils.allNotNull(vo.getActualWorkHours(), vo.getPlannedWorkHours())) {
@@ -373,7 +380,12 @@
        long pages = getPages(size,total);
        int startIndex = Math.toIntExact((current - 1) * size >= total ? (pages - 1) * size : (current - 1) * size);
        int endIndex = Math.toIntExact(Math.min(current * size, total));
        List<StaffAttendanceVO> records = resultList.subList(startIndex, endIndex);
        List<StaffAttendanceVO> records;
        if(resultList.isEmpty()){
            records = new ArrayList<>();
        }else{
            records = resultList.subList(startIndex, endIndex);
        }
        resultPage.setRecords(records);
        resultPage.setTotal(total);
        resultPage.setSize(size);