| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.moral.api.entity.Sensor; |
| | | import com.moral.api.mapper.HistoryHourlyMapper; |
| | | import com.moral.api.mapper.HistoryMinutelyMapper; |
| | |
| | | .collect(Collectors.groupingBy(o -> (String) o.get("mac"))); |
| | | |
| | | //存入数据库的结果集 |
| | | List<HistoryHourly> insertData = new ArrayList<>(); |
| | | List<Map<String, Object>> insertData = new ArrayList<>(); |
| | | |
| | | data.forEach((key, value) -> { |
| | | HistoryHourly historyHourly = new HistoryHourly(); |
| | | historyHourly.setMac(key); |
| | | historyHourly.setTime(end); |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | Map<String, Object> historyHourly = new HashMap<>(); |
| | | historyHourly.put("mac", key); |
| | | historyHourly.put("time", end); |
| | | |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", value); |
| | | map.put("type", "hour"); |
| | |
| | | } |
| | | } |
| | | }); |
| | | historyHourly.setValue(JSONObject.toJSONString(jsonMap)); |
| | | historyHourly.setVersion((Integer) value.get(0).get("version")); |
| | | historyHourly.put("version", value.get(0).get("version")); |
| | | historyHourly.put("value", JSONObject.toJSONString(jsonMap)); |
| | | insertData.add(historyHourly); |
| | | }); |
| | | |