| | |
| | | return list; |
| | | } |
| | | //电池数据历史实时处理(预警分析) |
| | | public List<ResAnalysis> getBattHisRealInAlm(BattRealdataId realdata, List<String> battList) { |
| | | String result = battList.stream().collect(Collectors.joining(",")); |
| | | public List<ResAnalysis> getBattHisRealInAlm(BattRealdataId realdata, Map<String,Integer> battMap) { |
| | | String result = String.join(",", battMap.keySet()); |
| | | String sql=" select record_time,"+result+" " + |
| | | " from db_data_history.tb_batt_realdata_"+realdata.getTableName()+" " + |
| | | " where record_time >= '"+ThreadLocalUtil.format(realdata.getRecordTime(),1)+"' " + |
| | |
| | | while (rs.next()){ |
| | | ResAnalysis ph=new ResAnalysis(); |
| | | ph.setRecordTime(rs.getTimestamp("record_time")); |
| | | for (int i=0;i<battList.size();i++){ |
| | | int i=1; |
| | | for (String key : battMap.keySet()) { |
| | | Integer dataType = battMap.get(key); |
| | | try { |
| | | Float value = rs.getFloat(battList.get(i)); |
| | | String propertyName = "dataName"+(i+1); |
| | | String propertyType = "dataType"+(i); |
| | | Field fieldType = ResAnalysis.class.getDeclaredField(propertyType); |
| | | fieldType.setAccessible(true); |
| | | fieldType.set(ph,dataType); |
| | | |
| | | Float value = rs.getFloat(key); |
| | | String propertyName = "dataName"+(i); |
| | | Field fieldName = ResAnalysis.class.getDeclaredField(propertyName); |
| | | fieldName.setAccessible(true); // 如果字段是私有的,需要设置为可访问 |
| | | fieldName.set(ph,battList.get(i)); |
| | | fieldName.set(ph,key); |
| | | |
| | | String propertyValue = "dataValue"+(i+1); |
| | | String propertyValue = "dataValue"+(i); |
| | | Field fieldValue = ResAnalysis.class.getDeclaredField(propertyValue); |
| | | fieldValue.setAccessible(true); |
| | | fieldValue.set(ph,value); |
| | |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | i++; |
| | | } |
| | | list.add(ph); |
| | | } |
| | |
| | | } |
| | | |
| | | //电源数据历史实时处理(预警分析) |
| | | public List<ResAnalysis> getPwrHisRealInAlm(PwrdevHistorydataId pwrHis, List<String> pwrList) { |
| | | String result = pwrList.stream().collect(Collectors.joining(",")); |
| | | public List<ResAnalysis> getPwrHisRealInAlm(PwrdevHistorydataId pwrHis, Map<String,Integer> pwrMap) { |
| | | String result = String.join(",", pwrMap.keySet()); |
| | | String sql=" select record_datetime,"+result+" " + |
| | | " from db_data_history.tb_pwrdev_historydata_"+pwrHis.getTableName()+" " + |
| | | " where record_datetime >= '"+ThreadLocalUtil.format(pwrHis.getRecordDatetime(),1)+"' " + |
| | |
| | | while (rs.next()){ |
| | | ResAnalysis ph=new ResAnalysis(); |
| | | ph.setRecordTime(rs.getTimestamp("record_datetime")); |
| | | for (int i=0;i<pwrList.size();i++){ |
| | | int i=1; |
| | | for (String key : pwrMap.keySet()) { |
| | | Integer dataType = pwrMap.get(key); |
| | | try { |
| | | Float value = rs.getFloat(pwrList.get(i)); |
| | | String propertyName = "dataName"+(i+1); |
| | | String propertyType = "dataType"+(i); |
| | | Field fieldType = ResAnalysis.class.getDeclaredField(propertyType); |
| | | fieldType.setAccessible(true); |
| | | fieldType.set(ph,dataType); |
| | | |
| | | Float value = rs.getFloat(key); |
| | | String propertyName = "dataName"+(i); |
| | | Field fieldName = ResAnalysis.class.getDeclaredField(propertyName); |
| | | fieldName.setAccessible(true); // 如果字段是私有的,需要设置为可访问 |
| | | fieldName.set(ph,pwrList.get(i)); |
| | | fieldName.set(ph,key); |
| | | |
| | | String propertyValue = "dataValue"+(i+1); |
| | | String propertyValue = "dataValue"+(i); |
| | | Field fieldValue = ResAnalysis.class.getDeclaredField(propertyValue); |
| | | fieldValue.setAccessible(true); |
| | | fieldValue.set(ph,value); |
| | |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | i++; |
| | | } |
| | | list.add(ph); |
| | | } |