kaiyu
2022-03-24 a827480e5e74cb6550c5f7b842bccac3023c5bdc
screen-job/src/main/java/com/moral/api/service/impl/HistoryDailyServiceImpl.java
@@ -79,17 +79,11 @@
        //存入数据库的结果集
        List<Map<String, Object>> insertData = new ArrayList<>();
        data.forEach((key, value) -> {
        data.forEach((mac, value) -> {
            Map<String, Object> dataMap = new HashMap<>();
            Map<String, Object> jsonMap = new HashMap<>();
            dataMap.put("mac", key);
            dataMap.put("mac", mac);
            dataMap.put("time", start);
            //中间变量,用于计算除臭氧外其它因子
            List<Map<String, Object>> tempValue = new ArrayList<>(value);
            //移除第一天数据(0点的),O3滑动值第一天数据是从1点-8点
            value.removeIf(map -> ((Date) map.get("time")).getTime() == start.getTime());
            Map<String, Object> params = new HashMap<>();
            params.put("data", value);
@@ -132,12 +126,8 @@
            if (!ObjectUtils.isEmpty(o3AvgOfDay)) {
                jsonMap.putAll(o3AvgOfDay);
            }
            //除臭氧外其他因子均值计算
            tempValue.removeIf(o -> ((Date) o.get("time")).getTime() == end.getTime());
            //风向均值计算并修约
            params.put("data", tempValue);
            Map<String, Object> windDirAvg = AmendUtils.getWindDirAvg(params);
            if (!ObjectUtils.isEmpty(windDirAvg)) {
                jsonMap.putAll(windDirAvg);
@@ -147,7 +137,7 @@
                String sensorCode = sensor.getCode();
                Double upper = sensor.getUpper();
                Double lower = sensor.getLower();
                OptionalDouble optionalDouble = tempValue.parallelStream()
                OptionalDouble optionalDouble = value.parallelStream()
                        .flatMapToDouble(v -> {
                            Map<String, Object> dataValue = JSONObject.parseObject((String) v.get("value"), Map.class);
                            Object sensorValue = dataValue.get(sensorCode);
@@ -158,7 +148,6 @@
                            }
                            if (ObjectUtils.isEmpty(sensorValue)) {
                                System.out.println(456);
                                return null;
                            }
@@ -170,19 +159,15 @@
                            //剔除数据超过上下限的数据
                            double aDouble = Double.parseDouble(sensorValue.toString());
                            if (!ObjectUtils.isEmpty(upper)) {
                                if (aDouble < upper) {
                                if (aDouble > upper) {
                                    return null;
                                }
                            }
                            if (!ObjectUtils.isEmpty(lower)) {
                                if (aDouble > lower) {
                                if (aDouble < lower) {
                                    return null;
                                }
                            }
                            if ("a00e12".equals(sensorCode)) {
                                System.out.println(key + "==" + sensorCode + "==" + v.get("time") + "==" + aDouble);
                            }
                            return DoubleStream.of(aDouble);
                        }).average();
                if (optionalDouble.isPresent()) {