From f5765e4ff4ea188e8a6ba4d66f3c4e7fc2268fdd Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Fri, 02 Jul 2021 17:20:29 +0800 Subject: [PATCH] 定时任务update --- screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java | 34 +++++++++++++++++++++++++++++----- 1 files changed, 29 insertions(+), 5 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 ed9a04a..7b31e16 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 @@ -63,6 +64,10 @@ //���������������������5������������ List<Map<String, Object>> fiveMinutelyData = historyMinutelyService.getHistoryFiveMinutelyData(params); + if (fiveMinutelyData.size() == 0) { + return; + } + //���mac������ Map<String, List<Map<String, Object>>> data = fiveMinutelyData.parallelStream() .collect(Collectors.groupingBy(o -> (String) o.get("mac"))); @@ -72,9 +77,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 +96,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)); @@ -94,12 +113,14 @@ }); //5��������������� - String insertTimeUnits = DateUtils.dateToDateString(new Date()); + 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 +175,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