From fdc8e1e781851904b05f234523f372c8c1098b69 Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Thu, 01 Jul 2021 11:42:45 +0800 Subject: [PATCH] 定时任务CO.O3算法 --- screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java index e762167..1b3c45d 100644 --- a/screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java +++ b/screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java @@ -21,6 +21,7 @@ import com.moral.api.service.HistoryMinutelyService; import com.moral.api.service.SensorService; import com.moral.constant.Constants; +import com.moral.util.AmendUtils; import com.moral.util.DateUtils; @Service @@ -72,9 +73,17 @@ data.forEach((key, value) -> { Map<String, Object> dataMap = new HashMap<>(); - Map<String, Object> jsonMap = new HashMap<>(); dataMap.put("mac", key); dataMap.put("time", end); + Map<String, Object> jsonMap = new HashMap<>(); + + //��������������������������� + Object windDirAvg = AmendUtils.getWindDirAvg(value); + if (windDirAvg != null) { + jsonMap.put(Constants.SENSOR_CODE_WIND_DIR, windDirAvg); + } + + //������������������������������������ sensorCodes.forEach(sensorCode -> { OptionalDouble optionalDouble = value.parallelStream() .flatMapToDouble(v -> { @@ -83,10 +92,16 @@ if (ObjectUtils.isEmpty(sensorValue)) { return null; } + //������������������ + if (Constants.SENSOR_CODE_WIND_DIR.equals(sensorCode)) { + return null; + } return DoubleStream.of(Double.parseDouble(sensorValue.toString())); }).average(); if (optionalDouble.isPresent()) { - jsonMap.put(sensorCode.toString(), Double.parseDouble(String.format("%.4f", optionalDouble.getAsDouble()))); + //��������������������� + double sciCal = AmendUtils.sciCal(optionalDouble.getAsDouble(), 4); + jsonMap.put(sensorCode.toString(), sciCal); } }); dataMap.put("value", JSONObject.toJSONString(jsonMap)); @@ -95,11 +110,13 @@ //5��������������� String insertTimeUnits = DateUtils.dateToDateString(now, DateUtils.yyyyMM_EN); + //��������������� historyFiveMinutelyMapper.insertHistoryFiveMinutely(insertData, insertTimeUnits); } + public static void main(String[] args) { - //������������ + /* //������������ List<Map<String, Object>> list = new ArrayList<>(); Map<String, Object> map1 = new HashMap<>(); map1.put("mac", "p5dnd1234567"); @@ -154,6 +171,9 @@ }); - System.out.println("666==" + insertData); + System.out.println("666==" + insertData);*/ + + double a = 5.5d; + System.out.println(Math.round(a)); } } -- Gitblit v1.8.0