| | |
| | | import com.whyc.mapper.BaoJiGroupUserMapper; |
| | | import com.whyc.mapper.BaoJiGroupBattGroupMapper; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.BaoJiGroup; |
| | | import com.whyc.pojo.BaoJiGroupUser; |
| | | import com.whyc.pojo.BaojiGroupBattGroup; |
| | | import com.whyc.pojo.StationInf; |
| | | import com.whyc.pojo.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | return mapper.selectList(query); |
| | | } |
| | | |
| | | public Response getGroupWithStationAndAlarmForScreen(int userId) { |
| | | try { |
| | | List<GroupWithStationAndAlarmDTO> list = mapper.getGroupWithStation(userId); |
| | | list.forEach(item -> { |
| | | List<StationInf> stationInfList = item.getStationInfList(); |
| | | List<StationInf> stationInfList2 = stationInfList.stream().collect(Collectors.collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StationInf::getTogetherFlag))), |
| | | ArrayList::new)); |
| | | item.setStationInfList(stationInfList2); |
| | | item.setStationCount(stationInfList2.size()); |
| | | List<String> stationIdList = stationInfList.stream().map(StationInf::getStationId).collect(Collectors.toList()); |
| | | //电池 |
| | | int battAlarmCount = battAlarmDataService.getCountByStationIds(stationIdList,1); |
| | | item.setBattAlarmCount(battAlarmCount); |
| | | //设备 |
| | | int deviceAlarmCount = deviceAlarmDataService.getCountByStationIds(stationIdList,1); |
| | | item.setDeviceAlarmCount(deviceAlarmCount); |
| | | //电源 |
| | | int powerAlarmCount = powerAlarmService.getCountByStationIds(stationIdList,1); |
| | | item.setPowerAlarmCount(powerAlarmCount); |
| | | }); |
| | | |
| | | return new Response().set(1, list); |
| | | }catch (Exception e){ |
| | | return new Response<>().set(1,false,"发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | public Response getGroupWithStationAndAlarm(int userId) { |
| | | try { |
| | | List<GroupWithStationAndAlarmDTO> list = mapper.getGroupWithStation(userId); |
| | | list.forEach(item -> { |
| | | List<StationInf> stationInfList = item.getStationInfList(); |
| | | stationInfList = stationInfList.stream().collect(Collectors.collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StationInf::getTogetherFlag))), |
| | | ArrayList::new)); |
| | | item.setStationInfList(stationInfList); |
| | | item.setStationCount(stationInfList.size()); |
| | | List<String> stationIdList = stationInfList.stream().map(StationInf::getStationId).collect(Collectors.toList()); |
| | | //电池 |
| | | int battAlarmCount = battAlarmDataService.getCountByStationIds(stationIdList); |
| | | item.setBattAlarmCount(battAlarmCount); |
| | | List<BattalarmData> battAlarmList = battAlarmDataService.getListByStationIds(stationIdList); |
| | | //设备 |
| | | int deviceAlarmCount = deviceAlarmDataService.getCountByStationIds(stationIdList); |
| | | item.setDeviceAlarmCount(deviceAlarmCount); |
| | | List<DevalarmData> deviceAlarmList = deviceAlarmDataService.getListByStationIds(stationIdList); |
| | | //电源 |
| | | int powerAlarmCount = powerAlarmService.getCountByStationIds(stationIdList); |
| | | item.setPowerAlarmCount(powerAlarmCount); |
| | | List<PwrdevAlarm> powerAlarmList = powerAlarmService.getListByStationIds(stationIdList); |
| | | //遍历每个告警列表,如果与站点相符,则加入到站点里面 |
| | | for (BattalarmData alarm : battAlarmList) { |
| | | for (StationInf stationInf : stationInfList) { |
| | | if(alarm.getStationId().equals(stationInf.getStationId())) { |
| | | List<BattalarmData> containList = stationInf.getBattAlarmList(); |
| | | if(containList == null){ |
| | | containList = new LinkedList<>(); |
| | | } |
| | | containList.add(alarm); |
| | | stationInf.setBattAlarmList(containList); |
| | | stationInf.setAlarmFlag(1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | for (DevalarmData alarm : deviceAlarmList) { |
| | | for (StationInf stationInf : stationInfList) { |
| | | if(alarm.getStationId().equals(stationInf.getStationId())) { |
| | | List<DevalarmData> containList = stationInf.getDeviceAlarmList(); |
| | | if(containList == null){ |
| | | containList = new LinkedList<>(); |
| | | } |
| | | containList.add(alarm); |
| | | stationInf.setDeviceAlarmList(containList); |
| | | stationInf.setAlarmFlag(1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | for (PwrdevAlarm alarm : powerAlarmList) { |
| | | for (StationInf stationInf : stationInfList) { |
| | | if(alarm.getStationId().equals(stationInf.getStationId())) { |
| | | List<PwrdevAlarm> containList = stationInf.getPowerAlarmList(); |
| | | if(containList == null){ |
| | | containList = new LinkedList<>(); |
| | | } |
| | | containList.add(alarm); |
| | | stationInf.setPowerAlarmList(containList); |
| | | stationInf.setAlarmFlag(1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | return new Response().set(1, list); |