| | |
| | | }); |
| | | return list; |
| | | } |
| | | //判断历史实时表是否存在 |
| | | public int judgeTable_realdata( String table){ |
| | | String sql="select count(*) as tableNum " + |
| | | " from INFORMATION_SCHEMA.TABLES " + |
| | | " where TABLE_SCHEMA = 'db_data_history' " + |
| | | " and TABLE_NAME = 'tb_batt_realdata_"+table+"'"; |
| | | 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("tableNum")); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return temp; |
| | | } |
| | | }); |
| | | int tableNum =0; |
| | | if(list!=null){ |
| | | tableNum= (int) list.get(0); |
| | | } |
| | | return tableNum; |
| | | } |
| | | |
| | | |
| | | public List<RealDateDTO> serchByCondition2(BattRealdataId realdata, int granularity) { |
| | | String sql=" select record_time, " + |
| | | " group_vol, " + |
| | | " online_vol, " + |
| | | " group_curr, " + |
| | | " mon_vol, " + |
| | | " mon_tmp, " + |
| | | " mon_res, " + |
| | | " mon_num " + |
| | | " from (select a.*, (@i:= @i+1) as number " + |
| | | " from (select * " + |
| | | " from db_data_history.tb_batt_realdata_"+realdata.getTableName()+" " + |
| | | " where record_time >= '"+ThreadLocalUtil.format(realdata.getRecordTime(),1)+"' " + |
| | | " and record_time <= '"+ThreadLocalUtil.format(realdata.getRecordTime1(),1)+"' ) a, " + |
| | | " (select @i:=0) b) c " + |
| | | " where c.number%"+granularity+"=0"; |
| | | List<RealDateDTO> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List<RealDateDTO> list=new ArrayList<>(); |
| | | while (rs.next()){ |
| | | RealDateDTO ph=new RealDateDTO(); |
| | | ph.setRecordTime(rs.getTimestamp("record_time")); |
| | | ph.setGroupVol(rs.getFloat("group_vol")); |
| | | ph.setOnlineVol(rs.getFloat("online_vol")); |
| | | ph.setGroupCurr(rs.getFloat("group_curr")); |
| | | ph.setMonVol(rs.getFloat("mon_vol")); |
| | | ph.setMonTmp(rs.getFloat("mon_tmp")); |
| | | ph.setMonRes(rs.getFloat("mon_res")); |
| | | ph.setMonNum(rs.getInt("mon_num")); |
| | | list.add(ph); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | } |