From a21f9150961e555475455e2d80ea3c5dd14e59d2 Mon Sep 17 00:00:00 2001 From: lxw <810412026@qq.com> Date: 星期五, 24 十一月 2023 12:11:06 +0800 Subject: [PATCH] ups告警实时和历史 --- src/main/java/com/whyc/service/SubTablePageInfoService.java | 128 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 127 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/whyc/service/SubTablePageInfoService.java b/src/main/java/com/whyc/service/SubTablePageInfoService.java index 522a408..6abb56c 100644 --- a/src/main/java/com/whyc/service/SubTablePageInfoService.java +++ b/src/main/java/com/whyc/service/SubTablePageInfoService.java @@ -3,6 +3,7 @@ import com.whyc.dto.InterfaceParam; import com.whyc.dto.ReportBattDTO; import com.whyc.dto.StandardFeatureCurve; +import com.whyc.dto.UpsAlarmDTO; import com.whyc.dto.paramter.AlarmPar; import com.whyc.dto.paramter.DevAlarmPar; import com.whyc.dto.result.AlarmRes; @@ -3204,5 +3205,130 @@ } return tableNum; } - + //鏌ヨups鍘嗗彶鍛婅鏁伴噺 + public int getCountForUps(UpsAlarmDTO param) { + String sql="select count(distinct alarm.num) as number from db_upspwrdev_alarm."+param.getRecordYear()+" alarm,db_pwrdev_inf.tb_pwrdev_inf inf " + + " where alarm.power_device_id = inf.PowerDeviceId "; +/* if(param.getStationName1()!=null){ + sql+=" and stationName1 like '%"+param.getStationName1()+"%'"; + } + if(param.getStationName2()!=null){ + sql+=" and stationName2 like '%"+param.getStationName2()+"%'"; + } + if(param.getStationName5()!=null){ + sql+=" and stationName5 like '%"+param.getStationName5()+"%'"; + } + if(param.getStationName3()!=null){ + sql+=" and stationName3 like '%"+param.getStationName3()+"%'"; + }*/ + if(param.getPwrdevId()!=0){ + sql+=" and alarm.power_device_id="+param.getPwrdevId(); + } + if(param.getAlmStartTime()!=null){ + sql+=" and alarm.alm_start_time >='"+ThreadLocalUtil.format(param.getAlmStartTime(),1)+"' "; + } + if(param.getAlmEndTime()!=null){ + sql+=" and alarm.alm_start_time <='"+ThreadLocalUtil.format(param.getAlmEndTime(),1)+"' "; + } + if(param.getAlmTypes()!=null&¶m.getAlmTypes().size()>0){ + sql+=" and alm_type in ( "; + for (int i=0;i<param.getAlmTypes().size();i++) { + sql+=param.getAlmTypes().get(i); + if(i!=(param.getAlmTypes().size()-1)){ + sql+=","; + } + } + sql+=")"; + } + sql+=" and alarm.power_device_id in ( select distinct inf.PowerDeviceId from" + + " (select PowerDeviceId,StationId from db_pwrdev_inf.tb_pwrdev_inf ) inf," + + " db_user.tb_user_battgroup_baojigroup_battgroup," + + " db_user.tb_user_battgroup_baojigroup_usr," + + " db_user.tb_user_inf" + + " where db_user.tb_user_battgroup_baojigroup_battgroup.StationId=inf.StationId" + + " and" + + " db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id" + + " and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid" + + " and db_user.tb_user_inf.uid="+param.getUsrId()+" )"; + List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { + @Override + public List getResults(ResultSet rs) throws SQLException { + LinkedList<Object> temp = new LinkedList<>(); + try { + while (rs.next()) + temp.add(rs.getInt("number")); + } catch (SQLException e) { + e.printStackTrace(); + } + return temp; + } + }); + int num =0; + if(list!=null){ + num= (int) list.get(0); + } + return num; + } + //鏌ヨups鍘嗗彶鍛婅 + public List getList2(UpsAlarmDTO param){ + String sql=" SELECT history.num,record_id,power_device_id,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type, " + + " inf.stationName,stationName1,stationName2,stationName3,stationName5,inf.PowerDeviceName as dev_name " + + " FROM db_upspwrdev_alarm."+param.getRecordYear()+" history,db_pwrdev_inf.tb_pwrdev_inf inf " + + " where history.power_device_id = inf.PowerDeviceId "; +/* if(param.getStationName1()!=null){ + if(param.getStationName1().equals("")){ + sql+=" and stationName1!='"+param.getStationName1()+"' "; + }else{ + sql+=" and stationName1='"+param.getStationName1()+"' "; + } + } + if(param.getStationName()!=null){ + if(param.getStationName().equals("")){ + sql+=" and stationName!='"+param.getStationName()+"' "; + }else{ + sql+=" and stationName='"+param.getStationName()+"' "; + } + }*/ + sql+=" and alm_start_time >='"+ThreadLocalUtil.format(param.getAlmStartTime(),1)+"' and alm_start_time <='"+ThreadLocalUtil.format(param.getAlmEndTime(),1)+"' "; + sql+=" and history.power_device_id in ( select distinct inf.PowerDeviceId from" + + " (select PowerDeviceId,StationId from db_pwrdev_inf.tb_pwrdev_inf ) inf," + + " db_user.tb_user_battgroup_baojigroup_battgroup," + + " db_user.tb_user_battgroup_baojigroup_usr," + + " db_user.tb_user_inf" + + " where db_user.tb_user_battgroup_baojigroup_battgroup.StationId=inf.StationId" + + " and" + + " db_user.tb_user_battgroup_baojigroup_usr.baoji_group_id=db_user.tb_user_battgroup_baojigroup_battgroup.baoji_group_id" + + " and db_user.tb_user_inf.uid=db_user.tb_user_battgroup_baojigroup_usr.uid" + + " and db_user.tb_user_inf.uid="+param.getUsrId()+" ) " + + " ORDER BY alm_start_time desc ,dev_name asc limit "+param.getLimitStart()+","+param.getLimitEnd()+" "; + List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { + @Override + public List getResults(ResultSet rs) throws SQLException { + List<UpspwrdevAlarmHistory> list=new ArrayList<>(); + while (rs.next()){ + UpspwrdevAlarmHistory ph=new UpspwrdevAlarmHistory(); + ph.setNum(rs.getLong("num")); + ph.setRecordId(rs.getLong("record_id")); + ph.setPowerDeviceId(rs.getLong("power_device_id")); + ph.setAlmType(rs.getInt("alm_type")); + ph.setAlmLevel(rs.getInt("alm_level")); + ph.setAlmStartTime(rs.getTimestamp("alm_start_time")); + ph.setAlmEndTime(rs.getTimestamp("alm_end_time")); + ph.setAlmValue(rs.getFloat("alm_value")); + ph.setAlmIsConfirmed(rs.getInt("alm_is_confirmed")); + ph.setAlmConfirmedTime(rs.getTimestamp("alm_confirmed_time")); + ph.setAlmClearedType(rs.getInt("alm_cleared_type")); + ph.setDevName(rs.getString("dev_name")); + ph.setStationName(rs.getString("stationName")); + ph.setStationName1(rs.getString("stationName1")); + ph.setStationName2(rs.getString("stationName2")); + ph.setStationName3(rs.getString("stationName3")); + ph.setStationName5(rs.getString("stationName5")); + list.add(ph); + } + return list; + } + }); + return list; + } } -- Gitblit v1.9.1