| | |
| | | //时间格式化:yyyy-MM-dd HH:mm |
| | | String format = DateUtils.yyyy_MM_dd_HH_mm_EN; |
| | | Date now = new Date(); |
| | | now = DateUtils.getFiveMinuteDate(now); |
| | | |
| | | //从数据库获取数据参数 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //开始时间 |
| | |
| | | data.forEach((key, value) -> { |
| | | Map<String, Object> dataMap = new HashMap<>(); |
| | | dataMap.put("mac", key); |
| | | dataMap.put("time", end); |
| | | dataMap.put("time", start); |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | |
| | | |
| | |
| | | Map<String, Object> dataValue = JSONObject.parseObject((String) v.get("value"), Map.class); |
| | | Object sensorValue = dataValue.get(sensorCode); |
| | | //数据有效性标记位 |
| | | Object flag = dataValue.get(sensorCode + Constants.MARKER_BIT_KEY); |
| | | Object flag = dataValue.get(sensorCode + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | return null; |
| | | } |
| | |
| | | //剔除数据超过上下限的数据 |
| | | double aDouble = Double.parseDouble(sensorValue.toString()); |
| | | if (!ObjectUtils.isEmpty(upper)) { |
| | | if (aDouble < upper) { |
| | | if (aDouble > upper) { |
| | | return null; |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(lower)) { |
| | | if (aDouble > lower) { |
| | | if (aDouble < lower) { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | }); |
| | | |
| | | //5分钟表后缀 |
| | | String insertTimeUnits = DateUtils.dateToDateString(now, DateUtils.yyyyMM_EN); |
| | | String insertTimeUnits = DateUtils.dateToDateString(DateUtils.getDateOfMin(now, -5), DateUtils.yyyyMM_EN); |
| | | //存入数据库 |
| | | historyFiveMinutelyMapper.insertHistoryFiveMinutely(insertData, insertTimeUnits); |
| | | } |