| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class DevalarmDataService { |
| | |
| | | public int getAlarmNum(int userId) { |
| | | return battDevAlarmDataMapper.searchNums(userId); |
| | | } |
| | | |
| | | public int getRealTimeWithLevel1(int userId) { |
| | | return battDevAlarmDataMapper.getRealTimeWithLevel1(userId); |
| | | } |
| | | |
| | | //今日实时告警 |
| | | public Response getDalmToday(int userId) { |
| | | try { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | int dtatolNum = 0; |
| | | Map<String, Integer> dAlmClearMap = new HashMap<>(); |
| | | dAlmClearMap.put("clear0", 0); |
| | | dAlmClearMap.put("clear1", 0); |
| | | List<DevalarmData> dAlmList = mapper.getDalmToday(userId); |
| | | Map<Integer, List<DevalarmData>> dclearedMap = dAlmList.stream().collect(Collectors.groupingBy(DevalarmData::getAlmClearedType)); |
| | | for (Integer cleared : dclearedMap.keySet()) { |
| | | dAlmClearMap.put("clear" + String.valueOf(cleared), dclearedMap.get(cleared).size()); |
| | | dtatolNum += dclearedMap.get(cleared).size(); |
| | | } |
| | | Map<String, Integer> dAlmLevelMap = new HashMap<>(); |
| | | dAlmLevelMap.put("level1", 0); |
| | | dAlmLevelMap.put("level2", 0); |
| | | dAlmLevelMap.put("level3", 0); |
| | | dAlmLevelMap.put("level4", 0); |
| | | Map<Integer, List<DevalarmData>> dlevelMap = dAlmList.stream().collect(Collectors.groupingBy(DevalarmData::getAlmLevel)); |
| | | for (Integer level : dlevelMap.keySet()) { |
| | | dAlmLevelMap.put("level" + String.valueOf(level), dlevelMap.get(level).size()); |
| | | //dtatolNum += dlevelMap.get(level).size(); |
| | | } |
| | | map.put("dAlmClearMap", dAlmClearMap); |
| | | map.put("dAlmLevelMap", dAlmLevelMap); |
| | | map.put("dtatolNum", dtatolNum); |
| | | return new Response().setII(1, true, map, "今日实时告警"); |
| | | } catch (Exception e) { |
| | | return new Response().set(1, false, "出现异常" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | public List<Integer> getStationList(int userId) { |
| | | return mapper.getStationList(userId); |
| | | } |
| | | |
| | | public int getCountByStationIds(List<String> stationIdList, Integer level) { |
| | | return mapper.getCountByStationIds(stationIdList, level); |
| | | } |
| | | |
| | | public List<DevalarmData> getListByStationIds(List<String> stationIdList) { |
| | | return mapper.getListByStationIds(stationIdList); |
| | | } |
| | | |
| | | |
| | | } |