| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.AlarmConstant; |
| | | import com.whyc.dto.AlarmDaoFactory; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.PwrdevAlarmMapper; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | @Service |
| | |
| | | } |
| | | return new Response().setII(1, list.size() > 0, list, "分级告警数"); |
| | | } |
| | | |
| | | /** |
| | | * +告警机房数和占比 |
| | | * @return |
| | | * @param userId |
| | | */ |
| | | public Response<List> getAcABCAnalysis(int userId){ |
| | | |
| | | //交流A/B/C-过压, |
| | | //交流A/B/C-欠压, |
| | | //交流A/B/C-缺相, |
| | | //交流A/B/C-过流 |
| | | Map<String,Integer> resultMap = new HashMap<>(); |
| | | resultMap.put("过压",0); |
| | | resultMap.put("欠压",0); |
| | | resultMap.put("缺相",0); |
| | | resultMap.put("过流",0); |
| | | |
| | | List<Integer> types = Arrays.asList( |
| | | AlarmConstant.acIn1_over_volA, |
| | | AlarmConstant.acIn1_over_volB, |
| | | AlarmConstant.acIn1_over_volC, |
| | | AlarmConstant.acIn1_under_volA, |
| | | AlarmConstant.acIn1_under_volB, |
| | | AlarmConstant.acIn1_under_volC, |
| | | AlarmConstant.acIn1_less_A, |
| | | AlarmConstant.acIn1_less_B, |
| | | AlarmConstant.acIn1_less_C, |
| | | AlarmConstant.acb1_over_currA, |
| | | AlarmConstant.acb1_over_currB, |
| | | AlarmConstant.acb1_over_currC); |
| | | |
| | | List<PwrdevAlarm> data = mapper.getAnalysis(userId,types); |
| | | |
| | | for (int i = 0; i < data.size(); i++) { |
| | | switch (data.get(i).getAlmType()){ |
| | | case AlarmConstant.acIn1_over_volA: |
| | | case AlarmConstant.acIn1_over_volB: |
| | | case AlarmConstant.acIn1_over_volC: |
| | | resultMap.put("过压",resultMap.get("过压")+data.get(i).getNum().intValue()); |
| | | break; |
| | | case AlarmConstant.acIn1_under_volA: |
| | | case AlarmConstant.acIn1_under_volB: |
| | | case AlarmConstant.acIn1_under_volC: |
| | | resultMap.put("欠压",resultMap.get("欠压")+data.get(i).getNum().intValue()); |
| | | break; |
| | | case AlarmConstant.acIn1_less_A: |
| | | case AlarmConstant.acIn1_less_B: |
| | | case AlarmConstant.acIn1_less_C: |
| | | resultMap.put("缺相",resultMap.get("缺相")+data.get(i).getNum().intValue()); |
| | | break; |
| | | case AlarmConstant.acb1_over_currA: |
| | | case AlarmConstant.acb1_over_currB: |
| | | case AlarmConstant.acb1_over_currC: |
| | | resultMap.put("过流",resultMap.get("过流")+data.get(i).getNum().intValue()); |
| | | break; |
| | | default: |
| | | throw new IllegalStateException("Unexpected value: " + data.get(i)); |
| | | } |
| | | |
| | | } |
| | | |
| | | //告警机房总数和比例 |
| | | HashMap<String, Integer> map2 = new HashMap<>(); |
| | | |
| | | //int alarmStationCount = mapper.getAlarmStationCountSpec(userId,types); |
| | | //int stationCount = infoMapper.getStationCount(userId); |
| | | |
| | | //map2.put("告警机房总数",alarmStationCount); |
| | | //map2.put("告警机房数比例",(int)MathUtil.divide(alarmStationCount,stationCount,2)); |
| | | |
| | | List<Map<String, Integer>> mapList = Arrays.asList(resultMap, map2); |
| | | return new Response<List>().set(1,mapList); |
| | | } |
| | | } |