From 709914b92b814f9f93ec38ed78054a8c831cc0fd Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Tue, 06 Jul 2021 14:00:02 +0800 Subject: [PATCH] redis常量update --- screen-job/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java | 34 ++++++++++++++++++++++++++++++---- 1 files changed, 30 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..4fc7ac3 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 @@ -2,6 +2,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import java.util.ArrayList; @@ -21,6 +22,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 @@ -41,6 +43,7 @@ } @Override + @Transactional public void insertHistoryFiveMinutely() { //������������������yyyy-MM-dd HH:mm String format = DateUtils.yyyy_MM_dd_HH_mm_EN; @@ -63,6 +66,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 +79,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 +98,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 +116,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 +177,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