ZhuDongming
2020-03-30 ce71e469c74ba4a8ae1fcdbf287ee86a033b7185
src/main/java/com/moral/task/RabbitMQInsertTask.java
@@ -378,6 +378,7 @@
            for (Map<String, Object> map : macAndOrganizationIdMap) {
                kv.put(map.get("mac").toString(), map.get("organizationId"));
            }
            int count = 0;
            for (int i = 0; i <= 358; i++) {
                LocalDateTime startTime = value.plusMinutes(i);
                LocalDateTime endTime = value.plusMinutes(i + 1);
@@ -388,7 +389,7 @@
                devices.put("macs", macList);
                devices.put("yearAndMonth", yearAndMonth);
                List<Map<String, Object>> realtimeData = historyMinutelyService.getMinutelySensorData(devices);
                XxlJobLogger.log("RabbitMQRealtimeMinutelyData:" + realtimeData.size());
                count += realtimeData.size();
                if (!CollectionUtils.isEmpty(realtimeData)) {
                    for (Map<String, Object> deviceData : realtimeData) {
                        if (!ObjectUtils.isEmpty(deviceData)) {
@@ -410,10 +411,12 @@
                            intersection.stream().forEach(parentId -> rabbitTemplate.convertAndSend(organization_data.getName(), parentId + "." + mac, JSON.toJSONString(deviceData)));
                        }
                    }
                }
            }
            XxlJobLogger.log("RabbitMQRealtimeMinutelyData:" + count);
                    ReturnT returnT = new ReturnT(200, "RabbitMQ分钟实时数据存入成功");
                    return returnT;
                }
            }
        } catch (Exception e) {
            XxlJobLogger.log("RabbitMQRealtimeMinutelyException:" + e.getMessage());
            logger.error(e.getMessage());
@@ -512,6 +515,7 @@
            for (Map<String, Object> map : macAndOrganizationIdMap) {
                kv.put(map.get("mac").toString(), map.get("organizationId"));
            }
            int count = 0;
            for (int i = 0; i <= 350; i = i + 5) {
                LocalDateTime startTime = value.plusMinutes(i);
                LocalDateTime endTime = value.plusMinutes(i + 5);
@@ -522,7 +526,7 @@
                devices.put("macs", macList);
                devices.put("yearAndMonth", yearAndMonth);
                List<Map<String, Object>> realtimeData = historyMinutelyService.getMinutelySensorData(devices);
                XxlJobLogger.log("RabbitMQRealtimeEveryFiveMinutesData:" + realtimeData.size());
                count += realtimeData.size();
                if (!CollectionUtils.isEmpty(realtimeData)) {
                    for (Map<String, Object> deviceData : realtimeData) {
                        if (!ObjectUtils.isEmpty(deviceData)) {
@@ -544,10 +548,11 @@
                            intersection.stream().forEach(parentId -> rabbitTemplate.convertAndSend(organization_data.getName(), parentId + "." + mac, JSON.toJSONString(deviceData)));
                        }
                    }
                }
            }
            XxlJobLogger.log("RabbitMQRealtimeEveryFiveMinutesData:" + count);
                    ReturnT returnT = new ReturnT(200, "RabbitMQ每5分钟实时数据存入成功");
                    return returnT;
                }
            }
        } catch (Exception e) {
            XxlJobLogger.log("RabbitMQRealtimeEveryFiveMinutesException:" + e.getMessage());
            logger.error(e.getMessage());
@@ -647,6 +652,7 @@
            for (Map<String, Object> map : macAndOrganizationIdMap) {
                kv.put(map.get("mac").toString(), map.get("organizationId"));
            }
            int count = 0;
            for (int i = 0; i <= 340; i = i + 10) {
                LocalDateTime startTime = value.plusMinutes(i);
                LocalDateTime endTime = value.plusMinutes(i + 1);
@@ -657,7 +663,7 @@
                devices.put("macs", macList);
                devices.put("yearAndMonth", yearAndMonth);
                List<Map<String, Object>> minutelyDataList = historyMinutelyService.getMinutelySensorData(devices);
                XxlJobLogger.log("RabbitMQMinutelyData:" + minutelyDataList.size());
                count += minutelyDataList.size();
                if (!CollectionUtils.isEmpty(minutelyDataList)) {
                    for (Map<String, Object> deviceData : minutelyDataList) {
                        if (!ObjectUtils.isEmpty(deviceData)) {
@@ -680,10 +686,11 @@
                            intersection.stream().forEach(parentId -> rabbitTemplate.convertAndSend(organization_data.getName(), parentId + "." + mac, JSON.toJSONString(minutelyData)));
                        }
                    }
                }
            }
            XxlJobLogger.log("RabbitMQMinutelyData:" + count);
                    ReturnT returnT = new ReturnT(200, "RabbitMQ分钟数据存入成功");
                    return returnT;
                }
            }
        } catch (Exception e) {
            XxlJobLogger.log("RabbitMQMinutelyException:" + e.getMessage());
            logger.error(e.getMessage());
@@ -780,6 +787,7 @@
            for (Map<String, Object> map : macAndOrganizationIdMap) {
                kv.put(map.get("mac").toString(), map.get("organizationId"));
            }
            int count = 0;
            for (int i = 0; i <= 6; i++) {
                LocalDateTime startTime = value.plusHours(i);
                LocalDateTime endTime = value.plusHours(i + 1);
@@ -789,7 +797,7 @@
                devices.put("end", endTime);
                devices.put("macs", macList);
                List<Map<String, Object>> hourlyDataList = historyHourlyService.getHourlySensorData(devices);
                XxlJobLogger.log("RabbitMQHourlyData:" + hourlyDataList.size());
                count += hourlyDataList.size();
                if (!CollectionUtils.isEmpty(hourlyDataList)) {
                    for (Map<String, Object> deviceData : hourlyDataList) {
                        if (!ObjectUtils.isEmpty(deviceData)) {
@@ -812,10 +820,11 @@
                            intersection.stream().forEach(parentId -> rabbitTemplate.convertAndSend(organization_data.getName(), parentId + "." + mac, JSON.toJSONString(hourlyData)));
                        }
                    }
                }
            }
            XxlJobLogger.log("RabbitMQHourlyData:" + count);
                    ReturnT returnT = new ReturnT(200, "RabbitMQ小时数据存入成功");
                    return returnT;
                }
            }
        } catch (Exception e) {
            XxlJobLogger.log("RabbitMQHourlyException:" + e.getMessage());
            logger.error(e.getMessage());