| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.service.DeviceService; |
| | |
| | | } |
| | | |
| | | //数据过滤 |
| | | data = data.entrySet().stream() |
| | | .filter(map -> { |
| | | String key = map.getKey(); |
| | | return !(key.contains("Min") || key.contains("Max") || key.contains("Cou")); |
| | | }).collect(Collectors.toMap(m -> m.getKey().replaceAll("-Avg", ""), Map.Entry::getValue)); |
| | | data.remove("time"); |
| | | data.remove("entryTime"); |
| | | Iterator<Map.Entry<String, Object>> iterator = data.entrySet().iterator(); |
| | | Map<String, Object> newMap = new HashMap<>(); |
| | | Map.Entry<String, Object> next; |
| | | while (iterator.hasNext()) { |
| | | next = iterator.next(); |
| | | String key = next.getKey(); |
| | | Object value = next.getValue(); |
| | | if (key.contains("-Avg")) { |
| | | newMap.put(key.replaceAll("-Avg", ""), value); |
| | | } else { |
| | | newMap.put(key, value); |
| | | } |
| | | iterator.remove(); |
| | | } |
| | | //存入数据库 |
| | | historyMinutelyService.insertHistoryMinutely(data); |
| | | historyMinutelyService.insertHistoryMinutely(newMap); |
| | | ack.acknowledge(); |
| | | } catch (Exception e) { |
| | | //log.error("param{}" + msg); |
| | | log.error("param{}" + msg); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //数据过滤 |
| | | data = data.entrySet().stream() |
| | | .filter(map -> { |
| | | String key = map.getKey(); |
| | | return !(key.contains("Min") || key.contains("Max") || key.contains("Cou")); |
| | | }).collect(Collectors.toMap(m -> m.getKey().replaceAll("-Avg", ""), Map.Entry::getValue)); |
| | | data.remove("time"); |
| | | data.remove("entryTime"); |
| | | Iterator<Map.Entry<String, Object>> iterator = data.entrySet().iterator(); |
| | | Map<String, Object> newMap = new HashMap<>(); |
| | | Map.Entry<String, Object> next; |
| | | while (iterator.hasNext()) { |
| | | next = iterator.next(); |
| | | String key = next.getKey(); |
| | | Object value = next.getValue(); |
| | | if (key.contains("-Avg")) { |
| | | newMap.put(key.replaceAll("-Avg", ""), value); |
| | | } else { |
| | | newMap.put(key, value); |
| | | } |
| | | iterator.remove(); |
| | | } |
| | | //存入数据库 |
| | | historyHourlyService.insertHistoryHourly(data); |
| | | historyHourlyService.insertHistoryHourly(newMap); |
| | | ack.acknowledge(); |
| | | } catch (Exception e) { |
| | | //log.error("param{}" + msg); |
| | | log.error("param{}" + msg); |
| | | } |
| | | } |
| | | |
| | |
| | | deviceService.judgeDeviceState(data); |
| | | ack.acknowledge(); |
| | | } catch (Exception e) { |
| | | //log.error("param{}" + msg); |
| | | log.error("param{}" + msg); |
| | | } |
| | | } |
| | | } |