From 258a769f6790f832d1c67839d59be04a118767e5 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期日, 28 四月 2024 10:50:48 +0800
Subject: [PATCH] 用时分析代码整理+注释整理
---
smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/TimeUsedAnalysisServiceImpl.java | 78 ++++++++++-----------------------------
1 files changed, 20 insertions(+), 58 deletions(-)
diff --git a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/TimeUsedAnalysisServiceImpl.java b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/TimeUsedAnalysisServiceImpl.java
index f4d714e..7ef3974 100644
--- a/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/TimeUsedAnalysisServiceImpl.java
+++ b/smart-man-boot/src/main/java/com/qianwen/smartman/modules/mdc/service/impl/TimeUsedAnalysisServiceImpl.java
@@ -96,7 +96,7 @@
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)) {
@@ -116,18 +116,7 @@
.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)) {
@@ -159,16 +148,16 @@
}).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));
}
@@ -182,7 +171,7 @@
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);
@@ -221,24 +210,20 @@
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));
}
@@ -257,29 +242,13 @@
.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();
@@ -442,7 +411,7 @@
}).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 -> {
@@ -451,15 +420,8 @@
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) {
@@ -899,7 +861,7 @@
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());
}
--
Gitblit v1.9.3