ZhuDongming
2020-03-31 8a765c7d88322bc7c67124cf21c39f6cff553a7e
update
1 files modified
36 ■■■■ changed files
src/main/java/com/moral/task/HistoryTableInsertTask.java 36 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/task/HistoryTableInsertTask.java
@@ -618,18 +618,19 @@
        LocalDateTime value = time.truncatedTo(ChronoUnit.DAYS);
        List<String> sensorKeys = sensorService.getSensorKeys();
        List<String> macs = deviceService.getMacs();
        for (int i = 0; i <= 5; i++) {
            LocalDateTime startTime = value.plusHours(i);
            LocalDateTime endTime = value.plusHours(i + 1);
            Map<String, Object> devices = new HashMap<>();
            devices.put("sensorKeys", sensorKeys);
            devices.put("start", startTime);
            devices.put("end", endTime);
            devices.put("macs", macs);
            devices.put("yearAndMonth", yearAndMonth);
            try {
        int count = 0;
        try {
            for (int i = 0; i <= 5; i++) {
                LocalDateTime startTime = value.plusHours(i);
                LocalDateTime endTime = value.plusHours(i + 1);
                Map<String, Object> devices = new HashMap<>();
                devices.put("sensorKeys", sensorKeys);
                devices.put("start", startTime);
                devices.put("end", endTime);
                devices.put("macs", macs);
                devices.put("yearAndMonth", yearAndMonth);
                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);
                    ReturnT returnT = new ReturnT(200, "插入小时表成功");
                    return returnT;
                }
            } catch (Exception e) {
                XxlJobLogger.log("historyHourlyException:" + e.getMessage());
                logger.error(e.getMessage());
                e.printStackTrace();
            }
            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;