| | |
| | | Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
|
| | | accountService.setOrgIdsByAccount(parameters);
|
| | | LocalDateTime time = LocalDateTime.now();
|
| | | // 当前时间 -10分钟
|
| | | LocalDateTime start = time.minusMinutes(10);
|
| | | parameters.put("start", start);
|
| | | parameters.put("end", time);
|
| | | // 当前时间 -5分钟
|
| | | LocalDateTime end = time.minusMinutes(5);
|
| | | parameters.put("end", end);
|
| | | LocalDateTime start = time.minusMinutes(5);
|
| | | parameters.put("start", start);
|
| | | List<Sensor> Sensors = sensorMapper.getSensorsByCriteria(parameters);
|
| | | List<String> sensorKeys = new ArrayList<String>();
|
| | | for (Sensor sensor : Sensors) {
|
| | |
| | | }
|
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMM");
|
| | | parameters.put("timeUnits", "minutely_" + df.format(start));
|
| | | parameters.put("timeUnits", "five_minutely_" + df.format(time));
|
| | | List<Map<String, Object>> list = historyMapper.getAreaAllDataByAccount(parameters);
|
| | | resultMap.putAll(list.get(0));
|
| | | return resultMap;
|
| | |
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | parameters.put("timeUnits", "hourly");
|
| | | List<Map<String, Object>> list = historyMapper.getAreaAllDataByAccount(parameters);
|
| | |
|
| | | for (Map<String, Object> map : list) {
|
| | | result.put((String) map.get("name"), map.get(macKey.toString()));
|
| | | }
|
| | |
| | | resultMap.put(map.remove("sensor_key").toString(), map);
|
| | | }
|
| | | return resultMap;
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | String timeUnits = startTime.substring(0, 10).replace("-", "");
|
| | | Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime, timeUnits);
|
| | | Map<String, Object> returnMap = new HashMap<>();
|
| | | if (map.isEmpty()) {
|
| | | returnMap.put("AQI", "N/V");
|
| | | if (ObjectUtils.isEmpty(map) || map.isEmpty()) {
|
| | | returnMap.put("AQI", "N/V");
|
| | | return returnMap;
|
| | | } else {
|
| | | Map<String, Double> AQIMap = new HashMap<>();
|
| | | for (Map.Entry<String, Object> entry : map.entrySet()) {
|
| | | String key = entry.getKey();
|
| | | Double value = Double.parseDouble(entry.getValue().toString());
|
| | | AQIMap.put(key, value);
|
| | | if (entry.getValue() != null) {
|
| | | Double value = Double.parseDouble(entry.getValue().toString());
|
| | | AQIMap.put(key, value);
|
| | | }
|
| | | }
|
| | | returnMap = AQICalculation.hourlyAQI(AQIMap);
|
| | | }
|
| | |
| | | String startTime = parameters.get("startTime").toString();
|
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
| | | LocalDateTime startTimeLocalDateTime = LocalDateTime.parse(startTime, dateTimeFormatter);
|
| | | LocalDateTime today = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
| | | LocalDateTime startTimeDay = startTimeLocalDateTime.truncatedTo(ChronoUnit.DAYS);
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
|
| | | int format = Integer.parseInt(sdf.format(new Date()));
|
| | | int year = startTimeLocalDateTime.getYear();
|
| | | int month = startTimeLocalDateTime.getMonthValue();
|
| | | String monthStr = month < 10 ? ("0" + month) : month + "";
|
| | |
| | | }
|
| | | parameters.put("sensorKeys", sensorKeys);
|
| | | List<Map<String, Object>> listMap = null;
|
| | | /*if (today.compareTo(startTimeDay) == 0) {
|
| | | listMap = historyMapper.listGetSensorData(parameters);
|
| | | }*/
|
| | | //if (CollectionUtils.isEmpty(listMap)) {
|
| | | listMap = historyMapper.getCarSensorData(parameters);
|
| | | if (CollectionUtils.isEmpty(listMap)) {
|
| | | if (year <= 2019) {
|
| | | listMap = historyMinutelyMapper.getSensorData(parameters);
|
| | | } else {
|
| | | parameters.put("yearAndMonth", yearAndMonth);
|
| | | listMap = historyMinutelyMapper.getSensorData2020(parameters);
|
| | | if (Integer.parseInt(yearAndMonth) <= format) {
|
| | | parameters.put("yearAndMonth", yearAndMonth);
|
| | | listMap = historyMinutelyMapper.getSensorData2020(parameters);
|
| | | }
|
| | | }
|
| | | }
|
| | | //}
|