| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | summary.put("avgTaskBeatDurationMs", list.isEmpty() || taskStartTime == null || taskEndTime == null |
| | | ? null |
| | | : durationMs(taskStartTime, taskEndTime) / list.size()); |
| | | summary.put("avgTaskPerHour", calculateAvgTaskPerHour(list.size(), summary.get("taskDurationMs"))); |
| | | summary.put("avgTotalDurationMs", average(list, item -> item.getTotalDurationMs() != null, WrkAnalysis::getTotalDurationMs)); |
| | | summary.put("avgStationDurationMs", average(list, item -> !METRIC_PARTIAL.equals(item.getMetricCompleteness()) && item.getStationDurationMs() != null, WrkAnalysis::getStationDurationMs)); |
| | | summary.put("avgCraneDurationMs", average(list, item -> !METRIC_PARTIAL.equals(item.getMetricCompleteness()) && item.getCraneDurationMs() != null, WrkAnalysis::getCraneDurationMs)); |
| | |
| | | return count == 0 ? null : total / count; |
| | | } |
| | | |
| | | private Double calculateAvgTaskPerHour(int taskCount, Object taskDurationMsValue) { |
| | | if (taskCount <= 0 || !(taskDurationMsValue instanceof Number)) { |
| | | return null; |
| | | } |
| | | long taskDurationMs = ((Number) taskDurationMsValue).longValue(); |
| | | if (taskDurationMs <= 0L) { |
| | | return null; |
| | | } |
| | | return BigDecimal.valueOf(taskCount * 3600000D / taskDurationMs) |
| | | .setScale(2, RoundingMode.HALF_UP) |
| | | .doubleValue(); |
| | | } |
| | | |
| | | private void applyRange(QueryWrapper<WrkMastLog> wrapper, String column, String rawValue) { |
| | | if (Cools.isEmpty(rawValue) || !rawValue.contains("~")) { |
| | | return; |