| | |
| | | result.put("version", version); |
| | | result.put("timeUnits", Constants.UN_ADJUST); |
| | | result.put("value", JSONObject.toJSONString(data)); |
| | | //原始数据(未校准) |
| | | historyHourlyMapper.insertHistoryHourlyUnAdjust(result); |
| | | //未校准小时表insert |
| | | historyHourlyMapper.insertHistoryHourly(result); |
| | | |
| | | //数据校准 |
| | | dataAdjust = deviceService.adjustDeviceData(dataAdjust); |
| | | dataAdjust.remove("mac"); |
| | | dataAdjust.remove("DataTime"); |
| | | dataAdjust.remove("ver"); |
| | | |
| | | 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)); |
| | | } |
| | | result.put("timeUnits", Constants.TRANSITION); |
| | | result.put("value", JSONObject.toJSONString(dataAdjust)); |
| | | //校准后中间小时表insert |
| | | historyHourlyMapper.insertHistoryHourly(result); |
| | | } |
| | | } |