| | |
| | | import com.whyc.mapper.CallBack; |
| | | import com.whyc.pojo.db_alarm.BattAlarmHistory; |
| | | import com.whyc.pojo.db_dis_batt.BattTestInfData; |
| | | import com.whyc.pojo.db_power_alarm.PowerAlarmHistory; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | //告警历史实时计算每张表查询总数 |
| | | //电池告警历史实时计算每张表查询总数 |
| | | public int getBattHisCount(BattAlarmHistory battAlarmHistory) { |
| | | String sql="SELECT count(*) as number FROM db_alarm."+ battAlarmHistory.getRecordYear()+" history " + |
| | | " where history.binf_id="+ battAlarmHistory.getBinfId() ; |
| | |
| | | } |
| | | return num; |
| | | } |
| | | //告警历史实时 |
| | | //电池告警历史实时 |
| | | public List<BattAlarmHistory> getBattHisList(BattAlarmHistory battAlarmHistory) { |
| | | String sql="SELECT * FROM db_alarm."+ battAlarmHistory.getRecordYear()+" history " + |
| | | " where history.binf_id="+ battAlarmHistory.getBinfId() ; |
| | |
| | | data.setMonNum(rs.getInt("mon_num")); |
| | | data.setAlmId(rs.getInt("alm_id")); |
| | | data.setAlmLevel(rs.getInt("alm_level")); |
| | | data.setAlmValue(rs.getFloat("alm_value")); |
| | | data.setAlmValue(rs.getInt("alm_value")); |
| | | list.add(data); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | //电源告警历史实时计算每张表查询总数 |
| | | public int getPowerHisCount(PowerAlarmHistory powerAlarmHistory) { |
| | | String sql="SELECT count(*) as number FROM db_power_alarm."+ powerAlarmHistory.getRecordYear()+" history " + |
| | | " where history.power_id="+ powerAlarmHistory.getPowerId() ; |
| | | if(powerAlarmHistory.getAlmStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(powerAlarmHistory.getAlmStartTime(),1)+"' "; |
| | | } |
| | | if(powerAlarmHistory.getAlmEndTime()!=null){ |
| | | sql+=" and alm_start_time <='"+ThreadLocalUtil.format(powerAlarmHistory.getAlmEndTime(),1)+"' "; |
| | | } |
| | | 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; |
| | | } |
| | | //电源告警历史实时 |
| | | public List<PowerAlarmHistory> getPowerHisList(PowerAlarmHistory powerAlarmHistory) { |
| | | String sql="SELECT * FROM db_power_alarm."+ powerAlarmHistory.getRecordYear()+" history " + |
| | | " where history.power_id="+ powerAlarmHistory.getPowerId() ; |
| | | if(powerAlarmHistory.getAlmStartTime()!=null){ |
| | | sql+=" and alm_start_time >='"+ ThreadLocalUtil.format(powerAlarmHistory.getAlmStartTime(),1)+"' "; |
| | | } |
| | | if(powerAlarmHistory.getAlmEndTime()!=null){ |
| | | sql+=" and alm_start_time <='"+ThreadLocalUtil.format(powerAlarmHistory.getAlmEndTime(),1)+"' "; |
| | | } |
| | | sql+=" ORDER BY alm_start_time asc limit "+ powerAlarmHistory.getLimitStart()+","+ powerAlarmHistory.getLimitEnd()+" "; |
| | | List<PowerAlarmHistory> list=sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList(); |
| | | while (rs.next()){ |
| | | PowerAlarmHistory data=new PowerAlarmHistory(); |
| | | data.setNum(rs.getInt("num")); |
| | | data.setPowerId(rs.getInt("power_id")); |
| | | data.setAlmStartTime(rs.getTimestamp("alm_start_time")); |
| | | data.setAlmEndTime(rs.getTimestamp("alm_end_time")); |
| | | data.setAlmId(rs.getInt("alm_id")); |
| | | data.setAlmLevel(rs.getInt("alm_level")); |
| | | data.setAlmValue(rs.getInt("alm_value")); |
| | | list.add(data); |
| | | } |
| | | return list; |