| | |
| | | " 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.getUId()+" " + |
| | | " )"; |
| | | sql+=" order by history.BattGroupId asc,history.alm_start_time desc,history.monnum asc limit "+param.getLimitStart()+","+param.getLimitEnd()+" "; |
| | | sql+=" order by history.alm_start_time desc,history.BattGroupId asc,history.monnum asc limit "+param.getLimitStart()+","+param.getLimitEnd()+" "; |
| | | |
| | | List<AlarmRes> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | |
| | | sqlExecuteService.makeManualCommit(sql_str); |
| | | } |
| | | |
| | | //预估 |
| | | public List<PredictDataId> getPredictDataId(int battGroupId, int testRecordCount) { |
| | | String sql=" SELECT distinct * FROM db_batt_testdata.tb_batttestdata_"+battGroupId+ |
| | | " WHERE test_record_count = " +testRecordCount+ |
| | | " order by record_num asc,mon_num asc "; |
| | | List<PredictDataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList<>(); |
| | | try { |
| | | while (rs.next()){ |
| | | PredictDataId data=new PredictDataId(); |
| | | data.setBattGroupId(rs.getInt("BattGroupId")); |
| | | data.setTestRecordCount(rs.getInt("test_record_count")); |
| | | data.setTestCap(rs.getFloat("test_type")); |
| | | data.setDataNew(rs.getInt("data_new")); |
| | | data.setDataAvailable(rs.getInt("data_available")); |
| | | data.setRecordNum(rs.getInt("record_num")); |
| | | data.setTestStarttime(rs.getTimestamp("test_starttime")); |
| | | data.setRecordTime(rs.getTimestamp("record_time")); |
| | | data.setTestTimelong(rs.getInt("test_timelong")); |
| | | data.setOnlineVol(rs.getFloat("online_vol")); |
| | | data.setGroupVol(rs.getFloat("group_vol")); |
| | | data.setTestCurr(rs.getFloat("test_curr")); |
| | | data.setTestCap(rs.getFloat("test_cap")); |
| | | data.setMonNum(rs.getInt("mon_num")); |
| | | data.setMonVol(rs.getFloat("mon_vol")); |
| | | data.setMonTmp(rs.getFloat("mon_tmp")); |
| | | list.add(data); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //2.取出最后一笔数据 |
| | | public List<PredictDataId> getPredictDataIdLast(int battGroupId, int testRecordCount, int maxRecordNum) { |
| | | String sql=" SELECT distinct * FROM db_batt_testdata.tb_batttestdata_"+battGroupId+ |
| | | " WHERE test_record_count = " +testRecordCount+" and record_num="+maxRecordNum+ |
| | | " order by record_num asc,mon_num asc "; |
| | | List<PredictDataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList<>(); |
| | | try { |
| | | while (rs.next()){ |
| | | PredictDataId data=new PredictDataId(); |
| | | data.setBattGroupId(rs.getInt("BattGroupId")); |
| | | data.setTestRecordCount(rs.getInt("test_record_count")); |
| | | data.setTestType(rs.getInt("test_type")); |
| | | data.setDataNew(rs.getInt("data_new")); |
| | | data.setDataAvailable(rs.getInt("data_available")); |
| | | data.setRecordNum(rs.getInt("record_num")); |
| | | data.setTestStarttime(rs.getTimestamp("test_starttime")); |
| | | data.setRecordTime(rs.getTimestamp("record_time")); |
| | | data.setTestTimelong(rs.getInt("test_timelong")); |
| | | data.setOnlineVol(rs.getFloat("online_vol")); |
| | | data.setGroupVol(rs.getFloat("group_vol")); |
| | | data.setTestCurr(rs.getFloat("test_curr")); |
| | | data.setTestCap(rs.getFloat("test_cap")); |
| | | data.setMonNum(rs.getInt("mon_num")); |
| | | data.setMonVol(rs.getFloat("mon_vol")); |
| | | data.setMonTmp(rs.getFloat("mon_tmp")); |
| | | list.add(data); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //3.取出预估对象的maxRecordNum之后的数据 |
| | | public List<PredictDataId> getPredictDataIdAgain(int battGroupId, int testRecordCount, int maxRecordNum) { |
| | | String sql=" SELECT distinct * FROM db_batt_testdata.tb_batttestdata_"+battGroupId+ |
| | | " WHERE test_record_count = " +testRecordCount+" and record_num>="+maxRecordNum+ |
| | | " order by record_num asc,mon_num asc "; |
| | | List<PredictDataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList<>(); |
| | | try { |
| | | while (rs.next()){ |
| | | PredictDataId data=new PredictDataId(); |
| | | data.setBattGroupId(rs.getInt("BattGroupId")); |
| | | data.setTestRecordCount(rs.getInt("test_record_count")); |
| | | data.setTestType(rs.getInt("test_type")); |
| | | data.setDataNew(rs.getInt("data_new")); |
| | | data.setDataAvailable(rs.getInt("data_available")); |
| | | data.setRecordNum(rs.getInt("record_num")); |
| | | data.setTestStarttime(rs.getTimestamp("test_starttime")); |
| | | data.setRecordTime(rs.getTimestamp("record_time")); |
| | | data.setTestTimelong(rs.getInt("test_timelong")); |
| | | data.setOnlineVol(rs.getFloat("online_vol")); |
| | | data.setGroupVol(rs.getFloat("group_vol")); |
| | | data.setTestCurr(rs.getFloat("test_curr")); |
| | | data.setTestCap(rs.getFloat("test_cap")); |
| | | data.setMonNum(rs.getInt("mon_num")); |
| | | data.setMonVol(rs.getFloat("mon_vol")); |
| | | data.setMonTmp(rs.getFloat("mon_tmp")); |
| | | list.add(data); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | //将数据插入id表 |
| | | public void addPredictDataId(int battGroupId, int testRecordCount2, List<PredictDataId> list2, List<PredictDataId> list1, Map<Integer,PredictDataId> mapDifference) { |
| | | ArrayList sql_str=new ArrayList(); |
| | | String tableName="db_batt_testdata."+"tb_batttestdata_"+battGroupId; |
| | | //先插入2 |
| | | if(list2!=null){ |
| | | String insertSql2="insert into "+tableName+" " |
| | | + "(" |
| | | + "BattGroupId," |
| | | + "test_record_count," |
| | | + "test_type," |
| | | + "data_new," |
| | | + "data_available," |
| | | + "record_num," |
| | | + "test_starttime," |
| | | + "record_time," |
| | | + "test_timelong," |
| | | + "online_vol," |
| | | + "group_vol," |
| | | + "test_curr," |
| | | + "test_cap," |
| | | + "mon_num," |
| | | + "mon_vol," |
| | | + "mon_tmp" |
| | | + ") " |
| | | + " values "; |
| | | for (int i=0;i<list2.size();i++) { |
| | | PredictDataId data2=list2.get(i); |
| | | String sql2="(" |
| | | +battGroupId+"," |
| | | + data2.getTestRecordCount()+"," |
| | | + data2.getTestType()+"," |
| | | + data2.getDataNew()+"," |
| | | + data2.getDataAvailable()+"," |
| | | + data2.getRecordNum()+1+"," |
| | | + "'"+ActionUtil.sdf.format(data2.getTestStarttime())+"'," |
| | | + "'"+ActionUtil.sdf.format(data2.getRecordTime())+"'," |
| | | + data2.getTestTimelong()+"," |
| | | + data2.getOnlineVol()+"," |
| | | + data2.getGroupVol()+"," |
| | | + data2.getTestCurr()+"," |
| | | + data2.getTestCap()+"," |
| | | + data2.getMonNum()+"," |
| | | + data2.getMonVol()+"," |
| | | + data2.getMonTmp()+"" |
| | | + ")";//如果对应是字符几个带上单引号 |
| | | insertSql2+=sql2; |
| | | } |
| | | sql_str.add(insertSql2); |
| | | } |
| | | //再插入1 |
| | | if(list1!=null){ |
| | | String insertSql1="insert into "+tableName+" " |
| | | + "(" |
| | | + "BattGroupId," |
| | | + "test_record_count," |
| | | + "test_type," |
| | | + "data_new," |
| | | + "data_available," |
| | | + "record_num," |
| | | + "test_starttime," |
| | | + "record_time," |
| | | + "test_timelong," |
| | | + "online_vol," |
| | | + "group_vol," |
| | | + "test_curr," |
| | | + "test_cap," |
| | | + "mon_num," |
| | | + "mon_vol," |
| | | + "mon_tmp" |
| | | + ") " |
| | | + " values "; |
| | | for (int i=0;i<list1.size();i++) { |
| | | PredictDataId data1=list1.get(i); |
| | | String sql1="(" |
| | | +battGroupId+"," |
| | | + data1.getTestRecordCount()+"," |
| | | + data1.getTestType()+"," |
| | | + data1.getDataNew()+"," |
| | | + data1.getDataAvailable()+"," |
| | | + data1.getRecordNum()+"," |
| | | + "'"+ActionUtil.sdf.format(data1.getTestStarttime())+"'," |
| | | + "'"+ActionUtil.sdf.format(data1.getRecordTime())+"'," |
| | | + data1.getTestTimelong()+mapDifference.get(data1.getMonNum()).getTestTimelong()+"," |
| | | + data1.getOnlineVol()+"," |
| | | + data1.getGroupVol()+"," |
| | | + data1.getTestCurr()+mapDifference.get(data1.getMonNum()).getTestCurr()+"," |
| | | + data1.getTestCap()+mapDifference.get(data1.getMonNum()).getTestCap()+"," |
| | | + data1.getMonNum()+"," |
| | | + data1.getMonVol()+mapDifference.get(data1.getMonNum()).getMonVol()+"," |
| | | + data1.getMonTmp()+mapDifference.get(data1.getMonNum()).getMonTmp()+"" |
| | | + ")";//如果对应是字符几个带上单引号 |
| | | insertSql1+=sql1; |
| | | } |
| | | sql_str.add(insertSql1); |
| | | } |
| | | sqlExecuteService.makeManualCommit(sql_str); |
| | | } |
| | | //获取当前天平均负载电流 |
| | | public Float getAvgLoadCurr(Integer powerId, String tableName) { |
| | | String sql=" select avg(load_curr) as avgCurr from "+tableName +" where DATE(record_time) = CURDATE() "; |
| | | List<Float> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List list=new ArrayList<>(); |
| | | try { |
| | | while (rs.next()){ |
| | | list.add(rs.getFloat("avgCurr")); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | float avgCurr=0f; |
| | | if (list!=null){ |
| | | avgCurr=list.get(0); |
| | | } |
| | | return avgCurr; |
| | | } |
| | | } |