| | |
| | | public void insertHistoryHourly(Map<String, Object> data) { |
| | | Map<String, Object> dataAdjust = new HashMap<>(data); |
| | | String mac = data.remove("mac").toString(); |
| | | Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | |
| | | Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN); |
| | | Integer version = (Integer) data.remove("ver"); |
| | | Map<String, Object> result = new HashMap<>(data); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("mac", mac); |
| | | result.put("time", time); |
| | | result.put("version", version); |
| | |
| | | dataAdjust.remove("mac"); |
| | | dataAdjust.remove("DataTime"); |
| | | dataAdjust.remove("ver"); |
| | | HistoryHourly historyHourly = new HistoryHourly(); |
| | | historyHourly.setMac(mac); |
| | | historyHourly.setTime(time); |
| | | historyHourly.setVersion(version); |
| | | historyHourly.setValue(JSONObject.toJSONString(dataAdjust)); |
| | | historyHourlyMapper.insert(historyHourly); |
| | | |
| | | int count = historyHourlyMapper.getCountByMacAndTime(mac, DateUtils.dateToDateString(time)); |
| | | |
| | | //判断中间表有没有该mac,该小时的数据,有就更新,没有就新增 |
| | | if (count == 0) { |
| | | //小时数据校准后存入小时中间表 |
| | | result.put("value", JSONObject.toJSONString(dataAdjust)); |
| | | //新增 |
| | | historyHourlyMapper.insertHistoryHourlyTransition(result); |
| | | } else { |
| | | //更新 |
| | | historyHourlyMapper.updateHistoryTransition(mac, DateUtils.dateToDateString(time)); |
| | | } |
| | | } |
| | | } |