| | |
| | | this.calendarService = calendarService; |
| | | } |
| | | |
| | | @Override // org.springblade.modules.mdc.service.ITimeUsedAnalysisService |
| | | @Override |
| | | public TimeUsedAnalysisWorkstationVO timeUsedStatisticsByWorkstation(TimeUsedStatisticsByWorkstationVO stationVO, Query query) { |
| | | Integer type = stationVO.getType(); |
| | | if (MdcConstant.WORK_STATION.equals(type)) { |
| | |
| | | .eq(Workstation::getStatus, CommonConstant.ENABLE) |
| | | .isNotNull(Workstation::getCalendarCode) |
| | | .orderByAsc(Workstation::getCode)); |
| | | /* |
| | | IPage<Workstation> page = this.workstationService.page(Condition.getPage(query), (Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().in(Func.isNotEmpty(ids), (v0) -> { |
| | | return v0.getId(); |
| | | }, ids).eq((v0) -> { |
| | | return v0.getType(); |
| | | }, WorkstationTypeEnum.MACHINE.getCode())).eq((v0) -> { |
| | | return v0.getStatus(); |
| | | }, CommonConstant.ENABLE)).isNotNull((v0) -> { |
| | | return v0.getCalendarCode(); |
| | | })).orderByAsc((v0) -> { |
| | | return v0.getCode(); |
| | | }));*/ |
| | | |
| | | long total = page.getTotal(); |
| | | List<Workstation> workstations = page.getRecords(); |
| | | if (Func.isEmpty(workstations)) { |
| | |
| | | }).collect(Collectors.toList()); |
| | | List<NameIdDTO> workStationDetails = Lists.newArrayList(); |
| | | List<List<CountStatusDTO>> countStatus = Lists.newArrayList(); |
| | | Set<Integer> wcsList = listGlobalWcs().stream().map(c -> { |
| | | return Integer.valueOf(Integer.parseInt(c.getCode())); |
| | | Set<Integer> wcsSet = listGlobalWcs().stream().map(c -> { |
| | | return Integer.parseInt(c.getCode()); |
| | | }).collect(Collectors.toSet()); |
| | | |
| | | List<SuperAggregateState> stateList = this.baseMapper.dateState(DateUtil.format(queryTime, "yyyyMMdd"), ids); |
| | | Map<Long, Map<Integer, Long>> map = buildStateMap(wcsList, stateList); |
| | | Map<Long, Map<Integer, Long>> map = buildStateMap(wcsSet, stateList); |
| | | for (Workstation workstation : workstations) { |
| | | workStationDetails.add(NameIdDTO.builder().id(workstation.getId()).name(workstation.getName() + "\n" + workstation.getCode()).build()); |
| | | Long id = workstation.getId(); |
| | | Map<Integer, Long> countResults = mergeMap(map.get(id), wcsList); |
| | | Map<Integer, Long> countResults = mergeMap(map.get(id), wcsSet); |
| | | log.info("day合并后:{}", countResults); |
| | | countStatus.add(buildCountStatus(countResults)); |
| | | } |
| | |
| | | List<NameIdDTO> workStationDetails = Lists.newArrayList(); |
| | | List<List<CountStatusDTO>> countStatus = Lists.newArrayList(); |
| | | Set<Integer> wcsList = listGlobalWcs().stream().map(c -> { |
| | | return Integer.valueOf(Integer.parseInt(c.getCode())); |
| | | return Integer.parseInt(c.getCode()); |
| | | }).collect(Collectors.toSet()); |
| | | List<SuperAggregateState> stateList = this.baseMapper.weekState(ids, year, week); |
| | | Map<Long, Map<Integer, Long>> map = buildStateMap(wcsList, stateList); |
| | |
| | | List<NameIdDTO> workStationDetails = Lists.newArrayList(); |
| | | List<List<CountStatusDTO>> countStatus = Lists.newArrayList(); |
| | | IPage<Workstation> workstationPages = this.workstationService.listWorkStationOnShiftIndex(ids, queryTime, query, shiftIndex, WorkstationTypeEnum.MACHINE.getCode()); |
| | | Set<Integer> wcsList = listGlobalWcs().stream().map(c -> { |
| | | return Integer.valueOf(Integer.parseInt(c.getCode())); |
| | | }).collect(Collectors.toSet()); |
| | | LinkedHashMap<String, List<Workstation>> calendarMap = workstationPages.getRecords().stream().collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getCalendarCode(); |
| | | }, LinkedHashMap::new, Collectors.toList())); |
| | | |
| | | Set<Integer> wcsSet = listGlobalWcs().stream().map(c -> Integer.parseInt(c.getCode())).collect(Collectors.toSet()); |
| | | |
| | | LinkedHashMap<String, List<Workstation>> calendarMap = workstationPages.getRecords().stream().collect(Collectors.groupingBy(Workstation::getCalendarCode, LinkedHashMap::new, Collectors.toList())); |
| | | calendarMap.forEach((calendarCode, workStationsList) -> { |
| | | List<Long> workStationIds = workStationsList.stream().map((v0) -> { |
| | | return v0.getId(); |
| | | }).collect(Collectors.toList()); |
| | | List<Long> workStationIds = workStationsList.stream().map(Workstation::getId).collect(Collectors.toList()); |
| | | List<SuperAggregateState> stateList = this.baseMapper.shiftState(workStationIds, DateUtil.format(queryTime, "yyyyMMdd"), shiftIndex, calendarCode); |
| | | Map<Long, Map<Integer, Long>> map = buildStateMap(wcsList, stateList); |
| | | Map<Long, Map<Integer, Long>> map = buildStateMap(wcsSet, stateList); |
| | | Iterator<Workstation> it = workStationsList.iterator(); |
| | | while (it.hasNext()) { |
| | | Workstation workstation = it.next(); |
| | | workStationDetails.add(NameIdDTO.builder().id(workstation.getId()).name(workstation.getName() + "\n" + workstation.getCode()).build()); |
| | | Long id = workstation.getId(); |
| | | Map<Integer, Long> countResults = mergeMap(map.get(id), wcsList); |
| | | Map<Integer, Long> countResults = mergeMap(map.get(id), wcsSet); |
| | | log.info("month合并后:{}", countResults); |
| | | countStatus.add(buildCountStatus(countResults)); |
| | | } |
| | |
| | | .eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory) |
| | | .in(Func.isNotEmpty(ids), CommonGroup::getId, ids)); |
| | | /* |
| | | long total = this.commonGroupService.count(((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)).in(Func.isNotEmpty(ids), (v0) -> { |
| | | return v0.getId(); |
| | | }, ids));*/ |
| | | |
| | | IPage<CommonGroup> page = this.commonGroupService.page(Condition.getPage(query), Wrappers.<CommonGroup>lambdaQuery() |
| | | .eq(CommonGroup::getGroupType, groupType) |
| | | .eq(CommonGroup::getGroupCategory, groupCategory) |
| | | .in(Func.isNotEmpty(ids), CommonGroup::getId, ids) |
| | | .orderByAsc(CommonGroup::getCode)); |
| | | /* |
| | | IPage<CommonGroup> page = this.commonGroupService.page(Condition.getPage(query), (Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getGroupType(); |
| | | }, groupType)).eq((v0) -> { |
| | | return v0.getGroupCategory(); |
| | | }, groupCategory)).in(Func.isNotEmpty(ids), (v0) -> { |
| | | return v0.getId(); |
| | | }, ids).orderByAsc((v0) -> { |
| | | return v0.getCode(); |
| | | }));*/ |
| | | |
| | | List<CommonGroup> groups = page.getRecords(); |
| | | if (Func.isEmpty(groups)) { |
| | | return new TimeUsedAnalysisWorkstationVO(); |
| | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | private Map<Long, Map<Integer, Long>> buildStateMap(Set<Integer> wcsList, List<SuperAggregateState> stateList) { |
| | | private Map<Long, Map<Integer, Long>> buildStateMap(Set<Integer> wcsSet, List<SuperAggregateState> stateList) { |
| | | List<SuperAggregateState> stateList2 = FilterOffUtils.filterOffDay(stateList, OpenTypeEnums.TIME_USED_ANALYSIS); |
| | | Timestamp ts = new Timestamp(System.currentTimeMillis()); |
| | | return stateList2.stream().peek(c -> { |
| | |
| | | c.setEndTime(ts); |
| | | } |
| | | c.setDurationCollect(Long.valueOf(LocalDateTimeUtils.betweenTwoTime(c.getStartTime().toLocalDateTime(), c.getEndTime().toLocalDateTime(), ChronoUnit.MILLIS))); |
| | | }).filter(c2 -> { |
| | | return (!wcsList.contains(c2.getValueCollect()) || c2.getValueCollect() == null || c2.getDurationCollect() == null) ? false : true; |
| | | }).collect(Collectors.groupingBy((v0) -> { |
| | | return v0.getWorkstationId(); |
| | | }, Collectors.groupingBy((v0) -> { |
| | | return v0.getValueCollect(); |
| | | }, Collectors.summingLong((v0) -> { |
| | | return v0.getDurationCollect(); |
| | | })))); |
| | | }).filter(c -> (wcsSet.contains(c.getValueCollect()) && c.getValueCollect() != null && c.getDurationCollect() != null)) |
| | | .collect(Collectors.groupingBy(SuperAggregateState::getWorkstationId, Collectors.groupingBy(SuperAggregateState::getValueCollect, Collectors.summingLong(SuperAggregateState::getDurationCollect)))); |
| | | } |
| | | |
| | | private Map<Integer, Long> buildStateGroupMap(Set<Integer> wcsList, List<SuperAggregateState> stateList) { |
| | |
| | | List<MixShiftDetailsDTO> result = Lists.newArrayList(); |
| | | calendarCodeMap.forEach((calendarCode, workstationList) -> { |
| | | List<ShiftIndexNameDTO> shiftDetails = this.calendarService.queryShiftIndexName(calendarCode, Integer.valueOf(localDate.getYear()), DateUtil.formatDate(localDate)); |
| | | this.calendarService.queryShiftIndexName(calendarCode, Integer.valueOf(localDate.getYear()), DateUtil.formatDate(localDate)); |
| | | //this.calendarService.queryShiftIndexName(calendarCode, Integer.valueOf(localDate.getYear()), DateUtil.formatDate(localDate)); |
| | | for (ShiftIndexNameDTO shiftDetail : shiftDetails) { |
| | | result.add(MixShiftDetailsDTO.builder().indexName(shiftDetail.getIndexName()).shiftIndex(shiftDetail.getShiftIndex()).mixShift(Boolean.FALSE).build()); |
| | | } |