Crunchy
2024-05-09 fb7bc35a49bac34373ee2ac93dc850d0b0f4444f
performance-server/src/main/java/com/yuanchu/mom/service/impl/PerformanceShiftServiceImpl.java
@@ -91,7 +91,7 @@
    }
    @Override
    public IPage<PerformanceShiftMapDto> performanceShiftPage(Page<Object> page, String time, String userName, String laboratory) {
    public Map<String, Object> performanceShiftPage(Page<Object> page, String time, String userName, String laboratory) {
        IPage<PerformanceShiftMapDto> mapIPage = baseMapper.performanceShiftPage(page, time, userName, laboratory);
        List<Enums> shiftType = enumService.selectEnumByCategory("班次类型");
        List<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYearPage(time, userName, laboratory);
@@ -117,10 +117,7 @@
                }
                hashMap.put("id", shiftTimeAndShift[2]);
                hashMap.put("shift", shiftTimeAndShift[1]);
                DateTime parse = DateUtil.parse(shiftTimeAndShift[0]);
                hashMap.put("weekly", DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1)));
                hashMap.put("time", shiftTimeAndShift[0]);
                hashMap.put("headerTime", getWeek(shiftTimeAndShift[0]));
                map.add(hashMap);
            }
            int totalYearAttendance = 0;
@@ -145,7 +142,26 @@
            i.setList(map);
            i.setShiftTime(null);
        });
        return mapIPage;
        // 获取header时间
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // 将字符串时间转换为 LocalDateTime 类型时间
        LocalDateTime localDateTime = LocalDateTime.parse(time, formatters);
        LocalDate firstDayOfMonth = localDateTime.toLocalDate().withDayOfMonth(1);
        LocalDate lastDayOfMonth = localDateTime.toLocalDate().with(TemporalAdjusters.lastDayOfMonth());
        List<LocalDateTime> localDateTimesBetween = getLocalDateTimesBetween(firstDayOfMonth.atStartOfDay(), lastDayOfMonth.atStartOfDay());
        List<Object> list1 = new ArrayList<>();
        for (LocalDateTime dateTime : localDateTimesBetween) {
            Map<Object, Object> hashMap = new HashMap<>();
            DateTime parse = DateUtil.parse(dateTime.format(formatter));
            hashMap.put("weekly", DateUtil.weekOfYear(DateUtil.offsetDay(parse, 1)));
            hashMap.put("headerTime", getWeek(dateTime.format(formatters)));
            list1.add(hashMap);
        }
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("page", mapIPage);
        resultMap.put("headerList", list1);
        return resultMap;
    }
    @Override
@@ -155,6 +171,17 @@
                .set(PerformanceShift::getShift, performanceShift.getShift()));
    }
//    public static void main(String[] args) {
//        String dateStr = "2023-09-15 12:30:45";
//        LocalDateTime localDateTime = convertToLocalDateTime(dateStr);
//        System.out.println(localDateTime);
//    }
//
//    public static LocalDateTime convertToLocalDateTime(String dateStr) {
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        return LocalDateTime.parse(dateStr, formatter);
//    }
    // 获取两个localDateTime的每一天
    public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) {
        List<LocalDateTime> localDateTimes = new ArrayList<>();