| | |
| | | private AlarmMapper alarmMapper; |
| | | |
| | | @Override |
| | | public void insertAlarmDaily() { |
| | | public int insertAlarmDaily() { |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | LocalDateTime endTime = time.truncatedTo(ChronoUnit.DAYS); |
| | | LocalDateTime startTime = endTime.minusDays(1); |
| | |
| | | devices.put("end", endTime); |
| | | devices.put("yearAndMonth", yearAndMonth); |
| | | List<String> macs = alarmMapper.getMacs(devices); |
| | | int count = 0; |
| | | for (String mac : macs) { |
| | | List<Map<String, Object>> resultList = new ArrayList<>(); |
| | | devices.put("mac", mac); |
| | |
| | | List<Map<String, Object>> newList = list.stream().distinct().collect(Collectors.toList()); |
| | | for (Map<String, Object> map : newList) { |
| | | for (String key : map.keySet()) { |
| | | String[] strings = map.get(key).toString().replace("$.", "") |
| | | .replace("[", "").replace("]", "") |
| | | .replace("\"", "").replace(" ", "").split(","); |
| | | String[] strings = map.get(key).toString().replace("$.", "") |
| | | .replace("[", "").replace("]", "") |
| | | .replace("\"", "").replace(" ", "").split(","); |
| | | |
| | | List<String> sensors = new ArrayList<String>(Arrays.asList(strings)); |
| | | map.put(key, sensors); |
| | | List<String> sensors = new ArrayList<String>(Arrays.asList(strings)); |
| | | map.put(key, sensors); |
| | | |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | for (String key : hashMap.keySet()) { |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mac",mac); |
| | | map.put("time",startTime); |
| | | map.put("state", key); |
| | | Set<String> sensors = (Set<String>) hashMap.get(key); |
| | | for (String sensor : sensors) { |
| | | jsonMap.put(sensor,1); |
| | | } |
| | | map.put("json",JSONUtils.toJSONString(jsonMap)); |
| | | resultList.add(map); |
| | | Map<String, Object> jsonMap = new HashMap<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mac", mac); |
| | | map.put("time", startTime); |
| | | map.put("state", key); |
| | | Set<String> sensors = (Set<String>) hashMap.get(key); |
| | | for (String sensor : sensors) { |
| | | jsonMap.put(sensor, 1); |
| | | } |
| | | map.put("json", JSONUtils.toJSONString(jsonMap)); |
| | | resultList.add(map); |
| | | } |
| | | alarmMapper.insertAlarmDaily(resultList); |
| | | count = count + alarmMapper.insertAlarmDaily(resultList); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | @Override |