yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.qianwen.smartman.modules.visual.wrapper;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.smartman.common.constant.CommonConstant;
import com.qianwen.smartman.common.constant.DateConstant;
import com.qianwen.core.tool.utils.DateUtil;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput;
import com.qianwen.smartman.modules.mdc.enums.OpenTypeEnums;
import com.qianwen.smartman.modules.mdc.utils.FilterOffUtils;
import com.qianwen.smartman.modules.system.entity.SeriesItem;
import com.qianwen.smartman.modules.system.vo.ChartSeriesDataVO;
import org.springframework.stereotype.Component;
 
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/visual/wrapper/OutputWrapper.class */
public class OutputWrapper {
    private static final Logger log = LoggerFactory.getLogger(OutputWrapper.class);
 
    public ChartSeriesDataVO getWorkstationOutput(List<SuperAggregateOutput> outputList, List<String> xList, String name, Integer type) {
        Map<String, Long> map;
        List<SuperAggregateOutput> outputList2 = FilterOffUtils.filterOffDay(outputList, OpenTypeEnums.OUT_PUT);
        ChartSeriesDataVO chartSeriesDataVO = new ChartSeriesDataVO();
        if (Func.isNotEmpty(outputList2)) {
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            if (CommonConstant.VERSION_NUM.equals(type)) {
                map = (Map) outputList2.stream().filter(o -> {
                    return Func.isNotEmpty(o.getTs());
                }).collect(Collectors.groupingBy(o2 -> {
                    return o2.getTs().toLocalDateTime().getDayOfMonth() + "-" + o2.getTs().toLocalDateTime().getHour();
                }, Collectors.summingLong((v0) -> {
                    return v0.getOutput();
                })));
            } else {
                map = (Map) outputList2.stream().filter(o3 -> {
                    return o3.getTs() != null;
                }).collect(Collectors.groupingBy(o4 -> {
                    return DateUtil.format(o4.getTs(), DateConstant.PATTERN_DATE);
                }, Collectors.summingLong((v0) -> {
                    return v0.getOutput();
                })));
            }
            Map<String, Long> map2 = map;
            xList.forEach(s -> {
                Long value = (Long) map2.get(s);
                if (value != null) {
                    arrayList2.add(value);
                } else {
                    arrayList2.add(0L);
                }
            });
            SeriesItem seriesItem = new SeriesItem();
            seriesItem.setName(name);
            seriesItem.setData(arrayList2);
            arrayList.add(seriesItem);
            chartSeriesDataVO.setCategories(xList);
            chartSeriesDataVO.setSeries(arrayList);
        }
        return chartSeriesDataVO;
    }
}