|
@@ -23,7 +23,7 @@ public class FaultMonitorServiceAImpl implements FaultMonitorService {
|
|
|
private FaultMonitorAMapper faultMonitorAMapper;
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Long> getTop5FaultyPartsNextMonthInThreeYears() {
|
|
|
+ public List<Map<String, Object>> getTop5FaultyPartsNextMonthInThreeYears() {
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
LocalDate nextMonth = currentDate.plusMonths(1);
|
|
|
int targetMonth = nextMonth.getMonthValue();
|
|
@@ -48,6 +48,7 @@ public class FaultMonitorServiceAImpl implements FaultMonitorService {
|
|
|
|
|
|
List<FaultMonitorA> faultMonitors = faultMonitorAMapper.selectList(queryWrapper);
|
|
|
|
|
|
+ // 按故障部件分组统计数量并转换为指定格式
|
|
|
return faultMonitors.stream()
|
|
|
.filter(this::isValidFaultPart)
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -57,16 +58,17 @@ public class FaultMonitorServiceAImpl implements FaultMonitorService {
|
|
|
.entrySet().stream()
|
|
|
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
|
|
.limit(5)
|
|
|
- .collect(Collectors.toMap(
|
|
|
- Map.Entry::getKey,
|
|
|
- Map.Entry::getValue,
|
|
|
- (e1, e2) -> e1,
|
|
|
- LinkedHashMap::new
|
|
|
- ));
|
|
|
+ .map(entry -> {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("partName", entry.getKey());
|
|
|
+ resultMap.put("count", entry.getValue());
|
|
|
+ return resultMap;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Long> getTop5FaultyPartsInSixMonths() {
|
|
|
+ public List<Map<String, Object>> getTop5FaultyPartsInSixMonths() {
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
LocalDate sixMonthsAgo = currentDate.minusMonths(6);
|
|
|
|
|
@@ -78,6 +80,7 @@ public class FaultMonitorServiceAImpl implements FaultMonitorService {
|
|
|
|
|
|
List<FaultMonitorA> faultMonitors = faultMonitorAMapper.selectList(queryWrapper);
|
|
|
|
|
|
+ // 按故障部件分组统计数量并转换为指定格式
|
|
|
return faultMonitors.stream()
|
|
|
.filter(this::isValidFaultPart)
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -87,12 +90,13 @@ public class FaultMonitorServiceAImpl implements FaultMonitorService {
|
|
|
.entrySet().stream()
|
|
|
.sorted(Map.Entry.<String, Long>comparingByValue().reversed())
|
|
|
.limit(5)
|
|
|
- .collect(Collectors.toMap(
|
|
|
- Map.Entry::getKey,
|
|
|
- Map.Entry::getValue,
|
|
|
- (e1, e2) -> e1,
|
|
|
- LinkedHashMap::new
|
|
|
- ));
|
|
|
+ .map(entry -> {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("partName", entry.getKey());
|
|
|
+ resultMap.put("count", entry.getValue());
|
|
|
+ return resultMap;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
// 辅助方法:LocalDate转Date
|
|
@@ -111,4 +115,4 @@ public class FaultMonitorServiceAImpl implements FaultMonitorService {
|
|
|
&& fault.getFaultyPartName() != null
|
|
|
&& !fault.getFaultyPartName().trim().isEmpty();
|
|
|
}
|
|
|
-}
|
|
|
+}
|