yangys
2024-03-29 e7aaa62a5c499747275a78ed6157024f15b9ab1e
smart-man-boot/src/main/java/com/qianwen/smartman/modules/report/service/impl/WorkstationEfficiencyServiceImpl.java
@@ -83,7 +83,7 @@
        }
        CommonUtil.fillWorkStationGroup(workstationVOPage);
        List<WorkstationDataDTO> workstationVOS = workstationVOPage.getRecords();
        List<Long> workstationIds = (List) workstationVOS.stream().map((v0) -> {
        List<Long> workstationIds = workstationVOS.stream().map((v0) -> {
            return v0.getWorkstationId();
        }).distinct().collect(Collectors.toList());
        List<SuperAggregateState> superAggregateStates = getStatusDataByFactoryDate(workstationIds, LocalDateTimeUtil.format(LocalDateUtil.dateToLocalDate(parse), "yyyyMMdd"), LocalDateTimeUtil.format(LocalDateUtil.dateToLocalDate(parse2), "yyyyMMdd"));
@@ -155,10 +155,10 @@
        workstationEfficiencyQueryVO.setEndTime(end);
        workstationEfficiencyQueryVO.setWorkstationIds(ids);
        List<SuperAggregateState> superAggregateStates = getStatusDataByFactoryDate(ids, start, end);
        Map<String, List<SuperAggregateState>> workstationAggregateStateMap = (Map) superAggregateStates.parallelStream().collect(Collectors.groupingBy(s -> {
        Map<String, List<SuperAggregateState>> workstationAggregateStateMap = superAggregateStates.parallelStream().collect(Collectors.groupingBy(s -> {
            return s.getWorkstationId() + "_" + s.getShiftIndex();
        }));
        Map<String, WorkstationEfficiencyVO> voMap = (Map) result.parallelStream().collect(LinkedHashMap::new, map, c -> {
        Map<String, WorkstationEfficiencyVO> voMap = (Map) result.parallelStream().collect(LinkedHashMap::new, (map, c) -> {
            WorkstationEfficiencyVO workstationEfficiencyVO = (WorkstationEfficiencyVO) map.put(c.getWorkstationId() + "_" + c.getShiftIndex() + "_" + c.getTime() + "_" + c.getType(), c);
        }, (v0, v1) -> {
            v0.putAll(v1);
@@ -195,15 +195,15 @@
                if (yearStateList.containsKey(year)) {
                    List<SuperAggregateState> stateYear = yearStateList.get(year);
                    if (Objects.equals(dateCycle, StatisticalMethodEnum.MONTH.getCode())) {
                        stateTime = (Map) stateYear.stream().collect(Collectors.groupingBy((v0) -> {
                        stateTime = stateYear.stream().collect(Collectors.groupingBy((v0) -> {
                            return v0.getFactoryMonth();
                        }));
                    } else if (Objects.equals(dateCycle, StatisticalMethodEnum.WEEK.getCode())) {
                        stateTime = (Map) stateYear.stream().collect(Collectors.groupingBy((v0) -> {
                        stateTime =  stateYear.stream().collect(Collectors.groupingBy((v0) -> {
                            return v0.getFactoryWeek();
                        }));
                    } else if (Objects.equals(dateCycle, StatisticalMethodEnum.DAY.getCode())) {
                        stateTime = (Map) stateYear.stream().collect(Collectors.groupingBy((v0) -> {
                        stateTime = stateYear.stream().collect(Collectors.groupingBy((v0) -> {
                            return v0.getFactoryDate();
                        }));
                    }
@@ -222,9 +222,9 @@
    }
    private <T, R extends WorkstationEfficiencyVO> void resultCount(Map<T, List<SuperAggregateState>> workstationAggregateStateMap, StatisticalMethodEnum anEnum, Map<String, R> voMap, List<Integer> productivityTypes) {
        workstationAggregateStateMap.forEach(key, list -> {
            Map<String, List<SuperAggregateState>> aggregateState = (Map) list.parallelStream().collect(Collectors.groupingBy(groupKey(anEnum)));
            aggregateState.forEach(k, v -> {
        workstationAggregateStateMap.forEach((key, list) -> {
            Map<String, List<SuperAggregateState>> aggregateState = list.parallelStream().collect(Collectors.groupingBy(groupKey(anEnum)));
            aggregateState.forEach((k, v) -> {
                ProductivityTypeEnum[] values = ProductivityTypeEnum.values();
                for (ProductivityTypeEnum productivityTypeEnum : values) {
                    WorkstationEfficiencyVO vo = (WorkstationEfficiencyVO) voMap.get(key + "_" + k + "_" + productivityTypeEnum.getMessage());
@@ -277,20 +277,20 @@
    private Map<Integer, List<Integer>> groupYear(Date startTime, Date endTime, Integer dateCycle) {
        LocalDate startLocal = LocalDateTimeUtils.dateToLocalDate(startTime);
        LocalDate endLocal = LocalDateTimeUtils.dateToLocalDate(endTime);
        HashMap hashMap = new HashMap();
        HashMap<Integer, List<Integer>> data = new HashMap<>();
        List<IntervalDateDto> dateDtos = LocalDateTimeUtils.getIntervalDate(startLocal, endLocal);
        for (IntervalDateDto intervalDateDto : dateDtos) {
            if (Objects.equals(dateCycle, StatisticalMethodEnum.MONTH.getCode())) {
                hashMap.put(intervalDateDto.getYear(), intervalDateDto.getMonthList());
               data.put(intervalDateDto.getYear(), intervalDateDto.getMonthList());
            } else if (Objects.equals(dateCycle, StatisticalMethodEnum.WEEK.getCode())) {
                hashMap.put(intervalDateDto.getYear(), intervalDateDto.getWeekList());
               data.put(intervalDateDto.getYear(), intervalDateDto.getWeekList());
            } else if (Objects.equals(dateCycle, StatisticalMethodEnum.DAY.getCode())) {
                hashMap.put(intervalDateDto.getYear(), intervalDateDto.getDayList().stream().map(item -> {
               data.put(intervalDateDto.getYear(), intervalDateDto.getDayList().stream().map(item -> {
                    return Integer.valueOf(DateUtil.format(DateUtil.parse(item, DateConstant.PATTERN_DATE), "yyyyMMdd"));
                }).collect(Collectors.toList()));
            }
        }
        return hashMap;
        return data;
    }
    private Function<SuperAggregateState, String> groupKey(StatisticalMethodEnum statisticalMethodEnum) {
@@ -327,14 +327,14 @@
                superAggregateStates.addAll(statusDataByFactoryDateAndWorkstationId);
            }
        }
        Date now = org.springblade.core.tool.utils.DateUtil.now();
        Date now = com.qianwen.core.tool.utils.DateUtil.now();
        superAggregateStates.forEach(x -> {
            if (Func.isEmpty(x.getEndTime())) {
                x.setEndTime(new Timestamp(now.getTime()));
            }
            x.setDurationCollect(Long.valueOf(LocalDateTimeUtils.betweenTwoTime(x.getStartTime().toLocalDateTime(), LocalDateTimeUtils.DateToLocalDateTime(x.getEndTime()), ChronoUnit.MILLIS)));
        });
        return (List) superAggregateStates.stream().filter(x2 -> {
        return superAggregateStates.stream().filter(x2 -> {
            return x2.getRps().intValue() > 0;
        }).collect(Collectors.toList());
    }