Browse Source

测试切入切出风速4

malijun 8 months ago
parent
commit
d31339600f
1 changed files with 14 additions and 12 deletions
  1. 14 12
      ruoyi-admin/src/test/java/com/ruoyi/ZhiBiaoCalculation.java

+ 14 - 12
ruoyi-admin/src/test/java/com/ruoyi/ZhiBiaoCalculation.java

@@ -13,10 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -133,11 +130,13 @@ public class ZhiBiaoCalculation {
             if (mapTurbineValues != null) {
                 AtomicReference<Double> sum = new AtomicReference<>(0.0);
                 //遍历mapTurbineValues,V大于10的舍弃,剩余算平均值
-                mapTurbineValues.forEach((k, v) -> {
-                    if (v > 10) {
-                        mapTurbineValues.remove(k);
+                for (Map.Entry<String, Double> entry : mapTurbineValues.entrySet()) {
+                    String key = entry.getKey();
+                    Double value = entry.getValue();
+                    if (value > 10) {
+                        mapTurbineValues.remove(key);
                     }
-                });
+                }
                 mapTurbineValues.forEach((k, v) -> {
                     sum.updateAndGet(v1 -> v1 + v);
                 });
@@ -149,11 +148,14 @@ public class ZhiBiaoCalculation {
 
             if (mapTurbineValues2 != null) {
                 AtomicReference<Double> sum = new AtomicReference<>(0.0);
-                mapTurbineValues2.forEach((k, v) -> {
-                    if (v > 10) {
-                        mapTurbineValues2.remove(k);
+
+                for (Map.Entry<String, Double> entry : mapTurbineValues2.entrySet()) {
+                    String key = entry.getKey();
+                    Double value = entry.getValue();
+                    if (value > 10) {
+                        mapTurbineValues2.remove(key);
                     }
-                });
+                }
                 mapTurbineValues2.forEach((k, v) -> {
                     sum.updateAndGet(v1 -> v1 + v);
                 });