yangys
2024-04-02 b773661de485d9748386bfdd15a7ac7cd399be36
smart-man-boot/src/main/java/com/qianwen/smartman/modules/visual/wrapper/VisualCountPulseWrapper.java
@@ -23,11 +23,7 @@
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/visual/wrapper/VisualCountPulseWrapper.class */
public class VisualCountPulseWrapper {
    static final /* synthetic */ boolean $assertionsDisabled;
    static {
        $assertionsDisabled = !VisualCountPulseWrapper.class.desiredAssertionStatus();
    }
    public static ChartSeriesDataVO<Long> visualCountDataByHour(DynamicCountDateAggregateDTO countAggregateDataDTO) {
        return visualCountDataByCondition(countAggregateDataDTO, ChronoUnit.HOURS, date -> {
@@ -42,13 +38,13 @@
    }
    public static ChartSeriesDataVO<Long> visualCountDataByShift(DynamicCountDateAggregateDTO countAggregateDataDTO) {
        Map<Long, Long> aggregateData = (Map) countAggregateDataDTO.getList().stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, Long> aggregateData = countAggregateDataDTO.getList().stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getWorkstationId();
        }, Collectors.summingLong((v0) -> {
            return v0.getOutput();
        })));
        WorkstationChartSeriesDataVO<Long> chartSeriesDataVO = new WorkstationChartSeriesDataVO<>();
        List<Long> data = (List) countAggregateDataDTO.getWorkstationList().stream().map(workstation -> {
        List<Long> data = countAggregateDataDTO.getWorkstationList().stream().map(workstation -> {
            return (Long) aggregateData.getOrDefault(workstation.getId(), 0L);
        }).collect(Collectors.toList());
        SeriesItem<Long> item = new SeriesItem<>(VisualConstant.SHIFT_OUTPUT, data);
@@ -58,57 +54,57 @@
    }
    private static ChartSeriesDataVO<Long> visualCountDataByCondition(DynamicCountDateAggregateDTO countAggregateDataDTO, ChronoUnit chronoUnit, Function<LocalDateTime, String> categoriesFormat) {
        UnaryOperator<LocalDateTime> unaryOperator;
        if ($assertionsDisabled || countAggregateDataDTO.getStartTime() != null) {
            if ($assertionsDisabled || countAggregateDataDTO.getEndTime() != null) {
                List<Workstation> workstationList = countAggregateDataDTO.getWorkstationList();
                Map<Long, String> categoriesSuffix = (Map) workstationList.stream().collect(Collectors.toMap((v0) -> {
                    return v0.getId();
                }, (v0) -> {
                    return v0.getName();
                }));
                List<SuperAggregateOutput> list = countAggregateDataDTO.getList();
                LocalDateTime startTime = countAggregateDataDTO.getStartTime();
                LocalDateTime endTime = countAggregateDataDTO.getEndTime();
                long between = chronoUnit.between(startTime, endTime);
                if (chronoUnit.equals(ChronoUnit.HOURS)) {
                    unaryOperator = date -> {
                        return date.plusHours(1L);
                    };
                } else {
                    unaryOperator = chronoUnit.equals(ChronoUnit.DAYS) ? date2 -> {
                        return date2.plusDays(1L);
                    } : null;
                }
                UnaryOperator<LocalDateTime> operator = unaryOperator;
                if ($assertionsDisabled || operator != null) {
                    List<String> categories = (List) Stream.iterate(startTime, operator).limit(between + 1).map(categoriesFormat).collect(Collectors.toList());
                    ChartSeriesDataVO<Long> chartSeriesDataVO = new ChartSeriesDataVO<>();
                    Map<Long, SeriesItem<Long>> seriesMap = new HashMap<>();
                    ((Map) list.stream().collect(Collectors.groupingBy((v0) -> {
                        return v0.getWorkstationId();
                    }))).forEach(id, aggregateOutputs -> {
                        Map<String, Long> collectMap = (Map) aggregateOutputs.stream().collect(Collectors.groupingBy(aggregate -> {
                            return (String) categoriesFormat.apply(aggregate.getTs().toLocalDateTime());
                        }, Collectors.summingLong((v0) -> {
                            return v0.getOutput();
                        })));
                        seriesMap.put(id, new SeriesItem((String) categoriesSuffix.get(id), (List) categories.stream().map(it -> {
                            return (Long) collectMap.getOrDefault(it, 0L);
                        }).collect(Collectors.toList())));
                    });
                    chartSeriesDataVO.setCategories(categories);
                    chartSeriesDataVO.setSeries((List) countAggregateDataDTO.getWorkstationList().stream().map(item -> {
                        return (SeriesItem) seriesMap.get(item.getId());
                    }).filter((v0) -> {
                        return Objects.nonNull(v0);
                    }).collect(Collectors.toList()));
                    return chartSeriesDataVO;
                }
                throw new AssertionError();
            }
            throw new AssertionError();
       assert countAggregateDataDTO.getStartTime() != null;
        assert countAggregateDataDTO.getEndTime() != null;
        //UnaryOperator<LocalDateTime> unaryOperator;
        List<Workstation> workstationList = countAggregateDataDTO.getWorkstationList();
        Map<Long, String> categoriesSuffix = workstationList.stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, (v0) -> {
            return v0.getName();
        }));
        List<SuperAggregateOutput> list = countAggregateDataDTO.getList();
        LocalDateTime startTime = countAggregateDataDTO.getStartTime();
        LocalDateTime endTime = countAggregateDataDTO.getEndTime();
        long between = chronoUnit.between(startTime, endTime);
        UnaryOperator<LocalDateTime> operator = chronoUnit.equals(ChronoUnit.HOURS) ? (date -> date.plusHours(1L)) : (chronoUnit.equals(ChronoUnit.DAYS) ? (date -> date.plusDays(1L)) : null);
        /*
        if (chronoUnit.equals(ChronoUnit.HOURS)) {
            unaryOperator = date -> {
                return date.plusHours(1L);
            };
        } else {
            unaryOperator = chronoUnit.equals(ChronoUnit.DAYS) ? date2 -> {
                return date2.plusDays(1L);
            } : null;
        }
        throw new AssertionError();
        UnaryOperator<LocalDateTime> operator = unaryOperator;
        */
        assert operator != null;
        List<String> categories = Stream.iterate(startTime, operator).limit(between + 1).map(categoriesFormat).collect(Collectors.toList());
        ChartSeriesDataVO<Long> chartSeriesDataVO = new ChartSeriesDataVO<>();
        Map<Long, SeriesItem<Long>> seriesMap = new HashMap<>();
        list.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getWorkstationId();
        })).forEach((id, aggregateOutputs) -> {
            Map<String, Long> collectMap = aggregateOutputs.stream().collect(Collectors.groupingBy(aggregate -> {
                return (String) categoriesFormat.apply(aggregate.getTs().toLocalDateTime());
            }, Collectors.summingLong((v0) -> {
                return v0.getOutput();
            })));
            seriesMap.put(id, new SeriesItem((String) categoriesSuffix.get(id), categories.stream().map(it -> {
                return (Long) collectMap.getOrDefault(it, 0L);
            }).collect(Collectors.toList())));
        });
        chartSeriesDataVO.setCategories(categories);
        chartSeriesDataVO.setSeries(countAggregateDataDTO.getWorkstationList().stream().map(item -> {
            return (SeriesItem) seriesMap.get(item.getId());
        }).filter((v0) -> {
            return Objects.nonNull(v0);
        }).collect(Collectors.toList()));
        return chartSeriesDataVO;
    }
}