| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class CKPowerDevAlarmService { |
| | |
| | | mapper.update(null,update); |
| | | return new Response().set(1,"确认完成"); |
| | | } |
| | | |
| | | public Response getCountByLevel() { |
| | | Map<Integer,Integer> countMap = new HashMap<>(); |
| | | countMap.put(0,0); |
| | | countMap.put(1,0); |
| | | countMap.put(2,0); |
| | | countMap.put(3,0); |
| | | QueryWrapper<CKPowerDevAlarm> query = Wrappers.query(); |
| | | query.select("alm_level"); |
| | | List<CKPowerDevAlarm> alarmList = mapper.selectList(query); |
| | | countMap.put(0,alarmList.size()); |
| | | Map<Integer, List<CKPowerDevAlarm>> levelMap = alarmList.stream().collect(Collectors.groupingBy(CKPowerDevAlarm::getAlmLevel)); |
| | | Set<Integer> levelKeyMap = levelMap.keySet(); |
| | | for (Integer level : levelKeyMap) { |
| | | countMap.put(level,levelMap.get(level).size()); |
| | | } |
| | | return new Response().set(1,countMap); |
| | | } |
| | | } |