yangys
2024-04-23 cacfe3693e552724a07ff65ee620cee91787da76
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/wrapper/StatisticsWrapper.java
@@ -31,7 +31,6 @@
import org.springframework.stereotype.Component;
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/mdc/wrapper/StatisticsWrapper.class */
public class StatisticsWrapper {
    private static final Logger log = LoggerFactory.getLogger(StatisticsWrapper.class);
    private final ITimeUsedAnalysisService timeUsedAnalysisService;
@@ -49,7 +48,7 @@
        Boolean isOutput = statisticsWrapperDto.getIsOutput();
        Integer queryType = statisticsAnalysisQueryVO.getQueryType();
        List<Integer> shiftIndexList = statisticsAnalysisQueryVO.getShiftIndexList();
        new StatisticsVO();
        ProductivityTypeEnum productivityType = statisticsAnalysisQueryVO.getProductivityType();
        switch (statisticsAnalysisQueryVO.getStatisticalMethod()) {
            case DAY:
@@ -77,7 +76,7 @@
                    break;
                }
            default:
                List<Long> workstationIds = (List) workstationPage.getRecords().stream().map((v0) -> {
                List<Long> workstationIds = workstationPage.getRecords().stream().map((v0) -> {
                    return v0.getId();
                }).collect(Collectors.toList());
                Map<Long, List<ShiftIndexNameDTO>> idToValue = this.timeUsedAnalysisService.queryWorkStationShiftIndex(workstationIds, statisticsAnalysisQueryVO.getStartDate());
@@ -89,7 +88,7 @@
    public StatisticsVO buildDateDataSheet(List<IntervalDateDto> intervalDates, List<SuperAggregate> superAggregates, IPage<Workstation> workstationIPage, Boolean isOutput, ProductivityTypeEnum productivityType) {
        StatisticsVO statisticsVO = new StatisticsVO();
        Map<Long, Map<Integer, List<SuperAggregate>>> collectGroupByDate = (Map) superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, Map<Integer, List<SuperAggregate>>> collectGroupByDate = superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getWorkstationId();
        }, Collectors.groupingBy((v0) -> {
            return v0.getFactoryDate();
@@ -102,7 +101,7 @@
            statisticsDataVO.setId(workstation.getId().toString());
            statisticsDataVO.setWorkstationCode(workstation.getCode());
            statisticsDataVO.setWorkstationName(workstation.getName());
            Map<Integer, List<SuperAggregate>> map = (Map) collectGroupByDate.get(workstation.getId());
            Map<Integer, List<SuperAggregate>> map = collectGroupByDate.get(workstation.getId());
            LinkedHashMap<String, String> data = new LinkedHashMap<>();
            if (Func.isEmpty(map)) {
                dayList.forEach(day -> {
@@ -110,7 +109,7 @@
                });
            } else {
                dayList.forEach(day2 -> {
                    List<SuperAggregate> superAggregateList = (List) map.get(Integer.valueOf(day2.replaceAll("-", "")));
                    List<SuperAggregate> superAggregateList = map.get(Integer.valueOf(day2.replaceAll("-", "")));
                    String value = getValue(superAggregateList, isOutput, productivityType);
                    data.put(day2, value);
                });
@@ -126,12 +125,12 @@
    }
    public StatisticsVO buildDateData(List<IntervalDateDto> intervalDates, List<SuperAggregate> superAggregates, List<Workstation> workstationList, Boolean isOutput, ProductivityTypeEnum productivityType) {
        Map<Long, Workstation> workstationIdToValue = (Map) workstationList.stream().collect(Collectors.toMap((v0) -> {
        Map<Long, Workstation> workstationIdToValue = workstationList.stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, v -> {
            return v;
        }));
        List<Long> workstationIdList = (List) workstationList.stream().map((v0) -> {
        List<Long> workstationIdList = workstationList.stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList());
        StatisticsVO statisticsVO = new StatisticsVO();
@@ -173,14 +172,14 @@
    public StatisticsVO buildMonthOrWeekDataSheet(List<IntervalDateDto> intervalDates, List<SuperAggregate> superAggregates, IPage<Workstation> workstationIPage, Boolean isMonth, Boolean isOutput, ProductivityTypeEnum productivityType) {
        StatisticsVO statisticsVO = new StatisticsVO();
        Map<Long, Map<Integer, Map<Integer, List<SuperAggregate>>>> collectGroupByMonth = (Map) superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, Map<Integer, Map<Integer, List<SuperAggregate>>>> collectGroupByMonth = superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getWorkstationId();
        }, Collectors.groupingBy((v0) -> {
            return v0.getFactoryYear();
        }, Collectors.groupingBy((v0) -> {
            return v0.getFactoryMonth();
        }))));
        Map<Long, Map<Integer, Map<Integer, List<SuperAggregate>>>> collectGroupByWeek = (Map) superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, Map<Integer, Map<Integer, List<SuperAggregate>>>> collectGroupByWeek = superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getWorkstationId();
        }, Collectors.groupingBy((v0) -> {
            return v0.getFactoryYear();
@@ -197,9 +196,9 @@
            statisticsDataVO.setWorkstationName(workstation.getName());
            LinkedHashMap<String, String> data = new LinkedHashMap<>();
            if (isMonth.booleanValue()) {
                yearMap = (Map) collectGroupByMonth.get(workstation.getId());
                yearMap = collectGroupByMonth.get(workstation.getId());
            } else {
                yearMap = (Map) collectGroupByWeek.get(workstation.getId());
                yearMap = collectGroupByWeek.get(workstation.getId());
            }
            if (Func.isEmpty(yearMap)) {
                intervalDates.forEach(intervalDateDto -> {
@@ -257,17 +256,17 @@
    public StatisticsVO buildMonthOrWeekData(List<IntervalDateDto> intervalDates, List<SuperAggregate> superAggregates, List<Workstation> workstationList, Boolean isMonth, Boolean isOutput, ProductivityTypeEnum productivityType) {
        Map<Integer, Map<Integer, Map<Long, List<SuperAggregate>>>> collectGroupByMonthOrWeek;
        Map<Long, Workstation> workstationIdToValue = (Map) workstationList.stream().collect(Collectors.toMap((v0) -> {
        Map<Long, Workstation> workstationIdToValue = workstationList.stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, v -> {
            return v;
        }));
        List<Long> workstationIdList = (List) workstationList.stream().map((v0) -> {
        List<Long> workstationIdList = workstationList.stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList());
        StatisticsVO statisticsVO = new StatisticsVO();
        if (isMonth.booleanValue()) {
            collectGroupByMonthOrWeek = (Map) superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
            collectGroupByMonthOrWeek =  superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
                return v0.getFactoryYear();
            }, Collectors.groupingBy((v0) -> {
                return v0.getFactoryMonth();
@@ -275,7 +274,7 @@
                return v0.getWorkstationId();
            }))));
        } else {
            collectGroupByMonthOrWeek = (Map) superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
            collectGroupByMonthOrWeek = superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
                return v0.getFactoryYear();
            }, Collectors.groupingBy((v0) -> {
                return v0.getFactoryWeek();
@@ -288,7 +287,7 @@
        intervalDates.forEach(intervalDateDto -> {
            List<Integer> monthOrWeekList;
            Integer year = intervalDateDto.getYear();
            Map<Integer, Map<Long, List<SuperAggregate>>> monthOrWeekToValue = (Map) finalCollectGroupByMonthOrWeek.get(year);
            Map<Integer, Map<Long, List<SuperAggregate>>> monthOrWeekToValue = finalCollectGroupByMonthOrWeek.get(year);
            if (isMonth.booleanValue()) {
                monthOrWeekList = intervalDateDto.getMonthList();
            } else {
@@ -340,8 +339,18 @@
        return statisticsVO;
    }
    /**
     * 构建效率分析的统计数据
     * @param superAggregates
     * @param workstationIPage
     * @param shiftIndexList
     * @param idToValue
     * @param isOutput
     * @param productivityType
     * @return
     */
    public StatisticsVO buildShiftData(List<SuperAggregate> superAggregates, IPage<Workstation> workstationIPage, List<Integer> shiftIndexList, Map<Long, List<ShiftIndexNameDTO>> idToValue, Boolean isOutput, ProductivityTypeEnum productivityType) {
        Map<Long, Map<Integer, List<SuperAggregate>>> collectGroupByShift = (Map) superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, Map<Integer, List<SuperAggregate>>> collectGroupByShift = superAggregates.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getWorkstationId();
        }, Collectors.groupingBy((v0) -> {
            return v0.getShiftIndex();
@@ -354,17 +363,17 @@
            statisticsDataVO.setId(String.valueOf(workstation.getId()));
            statisticsDataVO.setWorkstationCode(workstation.getCode());
            statisticsDataVO.setWorkstationName(workstation.getName());
            Map<Integer, List<SuperAggregate>> map = (Map) collectGroupByShift.get(workstation.getId());
            Map<Integer, List<SuperAggregate>> map = collectGroupByShift.get(workstation.getId());
            LinkedHashMap<String, String> data = new LinkedHashMap<>();
            LinkedHashMap<String, String> shiftData = new LinkedHashMap<>();
            List<ShiftIndexNameDTO> shiftDetails = (List) idToValue.get(workstation.getId());
            List<ShiftIndexNameDTO> shiftDetails = idToValue.get(workstation.getId());
            List<Integer> trueShiftIndexList = new ArrayList<>();
            Map<Integer, String> shiftIndexToName = new HashMap<>();
            if (Func.isNotEmpty(shiftDetails)) {
                trueShiftIndexList = (List) shiftDetails.stream().map((v0) -> {
                trueShiftIndexList = shiftDetails.stream().map((v0) -> {
                    return v0.getShiftIndex();
                }).collect(Collectors.toList());
                shiftIndexToName = (Map) shiftDetails.stream().collect(Collectors.toMap((v0) -> {
                shiftIndexToName = shiftDetails.stream().collect(Collectors.toMap((v0) -> {
                    return v0.getShiftIndex();
                }, (v0) -> {
                    return v0.getIndexName();
@@ -376,18 +385,19 @@
                shiftIndexList.forEach(shiftIndex -> {
                    if (finalTrueShiftIndexList.contains(shiftIndex)) {
                        data.put(shiftIndex.toString(), "0");
                       //data.put(shiftIndex.toString(), "0.88");
                        shiftData.put(shiftIndex.toString(), finalShiftIndexToName.get(shiftIndex));
                        return;
                    }
                    data.put(shiftIndex.toString(), "-");
                    shiftData.put(shiftIndex.toString(), MessageUtils.message("mdc.not.schedule", new Object[0]));
                });
            } else {
            } else {//有数据的情况下
                Map<Integer, String> finalShiftIndexToName1 = shiftIndexToName;
                List<Integer> finalTrueShiftIndexList1 = trueShiftIndexList;
                shiftIndexList.forEach(shiftIndex2 -> {
                    if (finalTrueShiftIndexList1.contains(shiftIndex2)) {
                        List<SuperAggregate> superAggregateList = (List) map.get(shiftIndex2);
                        List<SuperAggregate> superAggregateList = map.get(shiftIndex2);
                        String value = getValue(superAggregateList, isOutput, productivityType);
                        data.put(shiftIndex2.toString(), value);
                        shiftData.put(shiftIndex2.toString(), finalShiftIndexToName1.get(shiftIndex2));