| | |
| | | import com.whyc.pojo.PwrdevAlarmParam; |
| | | import com.whyc.pojo.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Resource |
| | | private PwrdevAlarmParamMapper paramMapper; |
| | | |
| | | @Autowired |
| | | private SubTablePageInfoService subService; |
| | | |
| | | //电源实时告警查询 |
| | | public Response getAllPage(PwrdevAlarm pwrdevAlarm){ |
| | | //分页信息 |
| | |
| | | for (PwrdevAlarm p:list) { |
| | | p.setAlarmName(AlarmDaoFactory.getAllAlarmName(p.getAlmType())); |
| | | if(p.getAlmIndex()!=0){ |
| | | p.setAlarmName(p.getAlarmName().replace("N","第"+p.getAlmIndex()+"路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N",p.getAlmIndex()+"")); |
| | | } |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | |
| | | for (PwrdevAlarm p:list) { |
| | | p.setAlarmName(AlarmDaoFactory.getAllAlarmName(p.getAlmType())); |
| | | if(p.getAlmIndex()!=0){ |
| | | p.setAlarmName(p.getAlarmName().replace("N","第"+p.getAlmIndex()+"路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N",p.getAlmIndex()+"")); |
| | | } |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | |
| | | } |
| | | adata.setAlarmName(AlarmDaoFactory.getAllAlarmName(adata.getAlmType())); |
| | | if(adata.getAlmIndex()!=0){ |
| | | adata.setAlarmName(adata.getAlarmName().replace("N","第"+adata.getAlmIndex()+"路")); |
| | | adata.setAlarmName(adata.getAlarmName().replace("N",adata.getAlmIndex()+"")); |
| | | } |
| | | } |
| | | return new Response().set(1,list); |
| | |
| | | wrapper.set("alm_is_confirmed",1); |
| | | wrapper.set("alm_confirmed_time",new SimpleDateFormat(ActionUtil.time_yyyyMMddHHmmss).format(new Date())); |
| | | wrapper.eq("num",num); |
| | | int flag=mapper.update(null,wrapper); |
| | | int flag=mapper.update((PwrdevAlarm) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(flag); |
| | | } |
| | | //电源实时取消告警 |
| | |
| | | wrapper.set("alm_is_confirmed",2); |
| | | wrapper.set("alm_confirmed_time",new SimpleDateFormat(ActionUtil.time_yyyyMMddHHmmss).format(new Date())); |
| | | wrapper.eq("num",num); |
| | | int flag=mapper.update(null,wrapper); |
| | | int flag=mapper.update((PwrdevAlarm) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(flag); |
| | | } |
| | | |
| | |
| | | return new Response().set(1, powerAlarmNum); |
| | | } |
| | | |
| | | //电源告警个数 |
| | | public int getAlarmNumByUserId(int userId) { |
| | | return mapper.getAlarmNum(userId); |
| | | } |
| | | //实时1级电源告警个数 |
| | | public int getRealTimeWithLevel1(int userId) { |
| | | return mapper.getRealTimeWithLevel1(userId); |
| | | } |
| | | |
| | | //山西晋源特定接口 |
| | | public int getRealTimeWithLevel1JY() { |
| | | return mapper.getRealTimeWithLevel1JY(); |
| | | } |
| | | |
| | | //首页电源总个数 |
| | | public int getHomeAlarmNum(int uId) { |
| | | int powerAlarmNum = mapper.getAlarmNum(uId); |
| | |
| | | List<String> tableList = paramMapper.getParamList(); |
| | | //取第一条记录,即param表 |
| | | String alarmParamTableName = tableList.get(0); |
| | | List<PwrdevAlarmParam> paramList = paramMapper.searchAll(alarmParamTableName); |
| | | //List<PwrdevAlarmParam> paramList = paramMapper.searchAll(alarmParamTableName); |
| | | List<PwrdevAlarmParam> paramList=subService.searchAll(alarmParamTableName); |
| | | for (PwrdevAlarm p:list) { |
| | | int almType = p.getAlmType(); |
| | | AtomicBoolean matchFlag = new AtomicBoolean(false); |
| | |
| | | int alarmIndex = p.getAlmIndex(); |
| | | if(alarmIndex!=0){ |
| | | p.setAlmIndex(alarmIndex); |
| | | p.setAlarmName(p.getAlarmName().replace("N","第"+alarmIndex+"路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N",alarmIndex+"")); |
| | | } |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | |
| | | List<String> tableList = paramMapper.getParamList(); |
| | | //取第一条记录,即param表 |
| | | String alarmParamTableName = tableList.get(0); |
| | | List<PwrdevAlarmParam> paramList=paramMapper.searchAll(alarmParamTableName); |
| | | //List<PwrdevAlarmParam> paramList=paramMapper.searchAll(alarmParamTableName); |
| | | List<PwrdevAlarmParam> paramList=subService.searchAll(alarmParamTableName); |
| | | for (PwrdevAlarm p:list) { |
| | | int almType = p.getAlmType(); |
| | | AtomicBoolean matchFlag = new AtomicBoolean(false); |
| | |
| | | int alarmIndex = p.getAlmIndex(); |
| | | if (alarmIndex != 0) { |
| | | p.setAlmIndex(alarmIndex); |
| | | p.setAlarmName(p.getAlarmName().replace("N", "第" + alarmIndex + "路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N", alarmIndex + "")); |
| | | } |
| | | } |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1, pageInfo); |
| | | } |
| | | |
| | | |
| | | //通信电源告警--认证送检-配电柜专用-webSocket |
| | | public Response getAllPage2OfWebSocket_pid(PwrdevAlarm pwrdevAlarm) { |
| | | //分页信息 |
| | | PageHelper.startPage(pwrdevAlarm.getPage().getPageCurr(), pwrdevAlarm.getPage().getPageSize()); |
| | | List<PwrdevAlarm> list=mapper.getAllPage2(pwrdevAlarm); |
| | | for (PwrdevAlarm p:list) { |
| | | int almType = p.getAlmType(); |
| | | AtomicBoolean matchFlag = new AtomicBoolean(false); |
| | | String alarmParamTableName="tb_pwrdev_alarm_param_"+p.getPowerDeviceId(); |
| | | List<PwrdevAlarmParam> paramList=subService.searchAll(alarmParamTableName); |
| | | if(paramList!=null){ |
| | | paramList.stream().forEach(param->{ |
| | | if(param.getAlarmId() == almType){ |
| | | p.setAlarmName(param.getAlarmName()); |
| | | matchFlag.set(true); |
| | | return; |
| | | } |
| | | }); |
| | | } |
| | | if (!matchFlag.get()) { |
| | | p.setAlarmName("未知告警类型"); |
| | | } |
| | | int alarmIndex = p.getAlmIndex(); |
| | | if (alarmIndex != 0) { |
| | | p.setAlmIndex(alarmIndex); |
| | | p.setAlarmName(p.getAlarmName().replace("N", alarmIndex + "")); |
| | | } |
| | | } |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1, pageInfo); |
| | | } |
| | | /** |
| | | * |
| | | * @param userId |
| | |
| | | //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); |
| | | return new Response<>().setII(1, true, mapList, ""); |
| | | } catch (Exception e) { |
| | | return new Response<>().set(0, false, "发生异常"); |
| | | return new Response<>().set(0, false, "发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | //山西晋源特定接口 |
| | | public Response getAcABCAnalysisJY(){ |
| | | |
| | | //交流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); |
| | | 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<PwrdevAlarm> data = mapper.getAnalysisJY(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: |
| | | } |
| | | |
| | | } |
| | | |
| | | //告警机房总数和比例 |
| | | HashMap<String, Integer> map2 = new HashMap<>(); |
| | | List<Map<String, Integer>> mapList = Arrays.asList(resultMap, map2); |
| | | return new Response<>().setII(1, true, mapList, ""); |
| | | } catch (Exception e) { |
| | | return new Response<>().set(0, false, "发生异常:"+e.getCause()); |
| | | } |
| | | } |
| | | |
| | | |
| | | //今日实时告警 |
| | | public Response getPalmToday(int userId) { |
| | |
| | | Map<Integer, List<PwrdevAlarm>> plevelMap = pAlmList.stream().collect(Collectors.groupingBy(PwrdevAlarm::getAlmLevel)); |
| | | for (Integer level : plevelMap.keySet()) { |
| | | pAlmLevelMap.put("level" + String.valueOf(level), plevelMap.get(level).size()); |
| | | ptatolNum += plevelMap.get(level).size(); |
| | | //ptatolNum += plevelMap.get(level).size(); |
| | | } |
| | | map.put("pAlmClearMap", pAlmClearMap); |
| | | map.put("pAlmLevelMap", pAlmLevelMap); |
| | |
| | | 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<PwrdevAlarm> getListByStationIds(List<String> stationIdList) { |
| | | return mapper.getListByStationIds(stationIdList); |
| | | } |
| | | } |