ZhuDongming
2020-03-31 8a765c7d88322bc7c67124cf21c39f6cff553a7e
src/main/java/com/moral/task/HistoryTableInsertTask.java
@@ -618,6 +618,8 @@
        LocalDateTime value = time.truncatedTo(ChronoUnit.DAYS);
        List<String> sensorKeys = sensorService.getSensorKeys();
        List<String> macs = deviceService.getMacs();
        int count = 0;
        try {
        for (int i = 0; i <= 5; i++) {
            LocalDateTime startTime = value.plusHours(i);
            LocalDateTime endTime = value.plusHours(i + 1);
@@ -627,9 +629,8 @@
            devices.put("end", endTime);
            devices.put("macs", macs);
            devices.put("yearAndMonth", yearAndMonth);
            try {
                List<Map<String, Object>> hourlyData = historyMinutelyService.getMinutelySensorData(devices);
                XxlJobLogger.log("historyHourlyData:" + hourlyData.size());
                count += hourlyData.size();
                List<Map<String, Object>> hourlyDataList = new ArrayList<>();
                for (Map<String, Object> deviceData : hourlyData) {
                    if (!ObjectUtils.isEmpty(deviceData)) {
@@ -654,14 +655,15 @@
                }
                if (!CollectionUtils.isEmpty(hourlyDataList)) {
                    historyHourlyService.insertHistoryHourly(hourlyDataList);
                }
            }
            XxlJobLogger.log("historyHourlyData:" + count);
                    ReturnT returnT = new ReturnT(200, "插入小时表成功");
                    return returnT;
                }
            } catch (Exception e) {
                XxlJobLogger.log("historyHourlyException:" + e.getMessage());
                logger.error(e.getMessage());
                e.printStackTrace();
            }
        }
        ReturnT returnT = new ReturnT(500, "插入小时表失败");
        return returnT;