whycxzp
2023-03-01 cb4a5cec6bad3e6273aa41cf6f4d798e058b523c
src/main/java/com/whyc/service/PwrdevAlarmService.java
@@ -218,7 +218,7 @@
     * @return
     * @param userId
     */
    public Response<List> getAcABCAnalysis(int userId){
    public Response getAcABCAnalysis(int userId){
        //交流A/B/C-过压,
        //交流A/B/C-欠压,
@@ -229,61 +229,63 @@
        resultMap.put("欠压",0);
        resultMap.put("缺相",0);
        resultMap.put("过流",0);
        try {
            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<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);
        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:
                }
        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<>().setII(1, true,mapList,null);
        }catch (Exception e){
            return new Response<>().set(0,false,"发生异常");
        }
        //告警机房总数和比例
        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);
    }
}