Commit b07390e9 authored by tangwei's avatar tangwei

去除influx

parent 36316fe9
...@@ -13,16 +13,16 @@ ...@@ -13,16 +13,16 @@
WHEN 'false' then '恢复' WHEN 'false' then '恢复'
ELSE event_movement end ) as eventMovement ELSE event_movement end ) as eventMovement
from from
fault_alarm_event fault_alarm_event
<where> <where>
<if test="gatewayId != null and gatewayId != ''"> <if test="gatewayId != null and gatewayId != ''">
gateway_id = #{gatewayId} gateway_id = #{gatewayId}
</if> </if>
<if test="stationId != null and stationId != ''"> <if test="stationId != null and stationId != ''">
station_id = #{stationId} station_id = #{stationId}
</if> </if>
</where> </where>
order by sort desc limit #{current},#{size} order by event_time desc
</select> </select>
......
...@@ -9,7 +9,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel; ...@@ -9,7 +9,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock; import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData; import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -55,25 +54,25 @@ public class DeviceController extends BaseController { ...@@ -55,25 +54,25 @@ public class DeviceController extends BaseController {
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) // @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取历史告警数据") // @ApiOperation(value = "获取历史告警数据")
@GetMapping("/historyNationwide") // @GetMapping("/historyNationwide")
public ResponseModel<ResultsData> getLSNationWideInfo(@RequestParam(value = "current") int current,@RequestParam // public ResponseModel<ResultsData> getLSNationWideInfo(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) { // (value = "size") int size,@RequestParam(value = "stationBasicId") String stationBasicId,@RequestParam(value = "equipmentNumber" , required = false ) String equipmentNumber) {
ResultsData resultsData=monitorFanIndicatorImpl.getLsNationWideInfo( current, size, stationBasicId, equipmentNumber); // ResultsData resultsData=monitorFanIndicatorImpl.getLsNationWideInfo( current, size, stationBasicId, equipmentNumber);
return ResponseHelper.buildResponse(resultsData); // return ResponseHelper.buildResponse(resultsData);
} // }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY) // @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "监盘大屏 - 获取历史告警数据") // @ApiOperation(value = "监盘大屏 - 获取历史告警数据")
@GetMapping("/historyNationwideByPage") // @GetMapping("/historyNationwideByPage")
public ResponseModel<Page<IndexDto>> historyNationwideByPage(@RequestParam(value = "current") int current, // public ResponseModel<Page<IndexDto>> historyNationwideByPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, // @RequestParam(value = "size") int size,
@RequestParam(value = "stationBasicId") String stationBasicId) { // @RequestParam(value = "stationBasicId") String stationBasicId) {
Page<IndexDto> resultsData = monitorFanIndicatorImpl.historyNationwideByPage( current, size, stationBasicId); // Page<IndexDto> resultsData = monitorFanIndicatorImpl.historyNationwideByPage( current, size, stationBasicId);
return ResponseHelper.buildResponse(resultsData); // return ResponseHelper.buildResponse(resultsData);
} // }
......
...@@ -11,8 +11,8 @@ public interface AlarmEventMapper extends BaseMapper<AlarmEvent> { ...@@ -11,8 +11,8 @@ public interface AlarmEventMapper extends BaseMapper<AlarmEvent> {
String getLastDataBySort(String gatewayId); String getLastDataBySort(String gatewayId);
List <AlarmEventDto> getAlarmEventList(String gatewayId,String stationId,int current, int size);
List <AlarmEventDto> getAlarmEventList(String gatewayId,String stationId);
List<String> getOldAlarmsBySort(String gatewayId, String sort); List<String> getOldAlarmsBySort(String gatewayId, String sort);
......
...@@ -16,8 +16,8 @@ public interface IMonitorFanIndicator { ...@@ -16,8 +16,8 @@ public interface IMonitorFanIndicator {
//批量修改指标值 //批量修改指标值
void UpdateMonitorFanIndicator(List<IndexDto> list); void UpdateMonitorFanIndicator(List<IndexDto> list);
ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); // ResultsData getNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber); // ResultsData getLsNationWideInfo( int current, int size, String stationBasicId, String equipmentNumber);
//
Map<String, Object> partofWaring3D(String stationId, String equipNum); // Map<String, Object> partofWaring3D(String stationId, String equipNum);
} }
...@@ -16,8 +16,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto; ...@@ -16,8 +16,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit; import com.yeejoin.amos.boot.module.jxiop.biz.initdata.StationCacheDataInit;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
...@@ -51,11 +50,11 @@ import java.util.stream.Collectors; ...@@ -51,11 +50,11 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class CommonServiceImpl { public class CommonServiceImpl {
@Autowired // @Autowired
InfluxDButils influxDButils; // InfluxDButils influxDButils;
@Autowired // @Autowired
InfluxdbUtil influxdbUtil; // InfluxdbUtil influxdbUtil;
@Autowired @Autowired
SjglZsjZsbtzMapper sjglZsjZsbtzMapper; SjglZsjZsbtzMapper sjglZsjZsbtzMapper;
...@@ -96,13 +95,13 @@ public class CommonServiceImpl { ...@@ -96,13 +95,13 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", totalvalue)); return Double.valueOf(String.format("%.2f", totalvalue));
} }
public Double getNumByIndicatior(String gatewayId,String indicator){ // public Double getNumByIndicatior(String gatewayId,String indicator){
String sql = "SELECT * FROM indicators_"+gatewayId+" where equipmentIndexName=~/"+indicator+"$/"; // String sql = "SELECT * FROM indicators_"+gatewayId+" where equipmentIndexName=~/"+indicator+"$/";
Double totalvalue = 0.0; // Double totalvalue = 0.0;
List<Map<String,Object>> mapList = influxdbUtil.query(sql); // List<Map<String,Object>> mapList = influxdbUtil.query(sql);
totalvalue =mapList.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).sum(); // totalvalue =mapList.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).sum();
return Double.valueOf(String.format("%.2f",totalvalue)); // return Double.valueOf(String.format("%.2f",totalvalue));
} // }
/** /**
* @deprecated 获取指标值平均值 * @deprecated 获取指标值平均值
...@@ -110,17 +109,17 @@ public class CommonServiceImpl { ...@@ -110,17 +109,17 @@ public class CommonServiceImpl {
* @param indicator 指标名称 查询条件-根据指标名称获取风速 * @param indicator 指标名称 查询条件-根据指标名称获取风速
* @return 指标值总和 * @return 指标值总和
*/ */
public Double getAvgvalueByIndicatior(String gatewayId,String indicator){ // public Double getAvgvalueByIndicatior(String gatewayId,String indicator){
String sql = "SELECT * FROM indicators_" + gatewayId + " where equipmentIndexName='" + indicator + "'"; // String sql = "SELECT * FROM indicators_" + gatewayId + " where equipmentIndexName='" + indicator + "'";
Double avageValue = 0.00; // Double avageValue = 0.00;
try { // try {
List<Map<String, Object>> mapList = influxdbUtil.query(sql); // List<Map<String, Object>> mapList = influxdbUtil.query(sql);
avageValue = mapList.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l -> Double.parseDouble((String) l.get("value"))).average().getAsDouble(); // avageValue = mapList.stream().filter(stringObjectMap -> !ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l -> Double.parseDouble((String) l.get("value"))).average().getAsDouble();
} catch (Exception e) { // } catch (Exception e) {
return avageValue; // return avageValue;
} // }
return Double.valueOf(String.format("%.2f", avageValue)); // return Double.valueOf(String.format("%.2f", avageValue));
} // }
public Double getTotalByIndicatior(List<Map<String,Object>> mapList,String indicator){ public Double getTotalByIndicatior(List<Map<String,Object>> mapList,String indicator){
Double totalvalue = 0.0; Double totalvalue = 0.0;
totalvalue =mapList.stream().filter(stringObjectMap ->stringObjectMap.get("equipmentIndexName").toString().contains(indicator)&&!ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).sum(); totalvalue =mapList.stream().filter(stringObjectMap ->stringObjectMap.get("equipmentIndexName").toString().contains(indicator)&&!ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).sum();
...@@ -136,6 +135,8 @@ public class CommonServiceImpl { ...@@ -136,6 +135,8 @@ public class CommonServiceImpl {
avageValue =mapList.stream().filter(stringObjectMap ->stringObjectMap.get("equipmentIndexName").toString().contains(indicator)&&!ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).sum(); avageValue =mapList.stream().filter(stringObjectMap ->stringObjectMap.get("equipmentIndexName").toString().contains(indicator)&&!ObjectUtils.isEmpty(stringObjectMap.get("value"))).mapToDouble(l->Double.parseDouble((String) l.get("value"))).sum();
return Double.valueOf(String.format("%.2f",avageValue)); return Double.valueOf(String.format("%.2f",avageValue));
} }
public Double getStationCapactityByStationWerks(String WERKS){ public Double getStationCapactityByStationWerks(String WERKS){
return sjglZsjZsbtzMapper.getStationCapactityByStationWerks(WERKS); return sjglZsjZsbtzMapper.getStationCapactityByStationWerks(WERKS);
} }
...@@ -233,7 +234,48 @@ public class CommonServiceImpl { ...@@ -233,7 +234,48 @@ public class CommonServiceImpl {
return stationCacheInfoDtos; return stationCacheInfoDtos;
} }
/**
* 根据查询条件获取列表信息
*
* @param mustQuerCondtion
* @param shouldQuerCondtion
* @param tClass
* @param <T>
* @param likeMap 模糊字段查询 key:不能带.keyWords
* @return
*/
public <T> List<T> getListDataByCondtionsAndLike(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Class<T> tClass, Map<String, String> likeMap) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(mustQuerCondtion)) {
for (String key : mustQuerCondtion.keySet()) {
List<String> va = mustQuerCondtion.get(key);
queryBuilder.must(QueryBuilders.termsQuery(key, va));
}
}
if (!ObjectUtils.isEmpty(shouldQuerCondtion)) {
for (String key : shouldQuerCondtion.keySet()) {
queryBuilder.should(QueryBuilders.wildcardQuery(key, shouldQuerCondtion.get(key)));
}
}
if (!ObjectUtils.isEmpty(likeMap)) {
for (String key : likeMap.keySet()) {
MatchPhraseQueryBuilder queryBuilder1 = QueryBuilders.matchPhraseQuery(key, "*" + likeMap.get(key) + "*");
queryBuilder.must(queryBuilder1);
}
}
Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder)
.build();
query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, tClass);
if (search.hasSearchHits()) {
List<SearchHit<T>> searchHitList = search.getSearchHits();
List<T> list = searchHitList.stream().map(hit -> hit.getContent()).collect(Collectors.toList());
return list;
}
return new ArrayList<>();
}
/* /*
*分组求和 *分组求和
......
...@@ -12,7 +12,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESDailyPowerGenerationR ...@@ -12,7 +12,6 @@ import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESDailyPowerGenerationR
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESMoonPowerGenerationRepository; import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESMoonPowerGenerationRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESYearPowerGenerationRepository; import com.yeejoin.amos.boot.module.jxiop.biz.repository.ESYearPowerGenerationRepository;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
...@@ -32,8 +31,8 @@ import java.util.List; ...@@ -32,8 +31,8 @@ import java.util.List;
@Service @Service
public class PowerGenerationImpl { public class PowerGenerationImpl {
@Autowired // @Autowired
InfluxDButils influxDButils; // InfluxDButils influxDButils;
@Autowired @Autowired
private ElasticsearchRestTemplate elasticsearchTemplate; private ElasticsearchRestTemplate elasticsearchTemplate;
@Autowired @Autowired
...@@ -45,28 +44,28 @@ public class PowerGenerationImpl { ...@@ -45,28 +44,28 @@ public class PowerGenerationImpl {
@Autowired(required=true) @Autowired(required=true)
IndicatorDataMapper indicatorDataMapper; IndicatorDataMapper indicatorDataMapper;
//获取指定指标,当天最后一条数据 // //获取指定指标,当天最后一条数据
public List<IndexDto> getlast(String gatewayId, String value,String daty){ // public List<IndexDto> getlast(String gatewayId, String value,String daty){
IndexDto indexDto=null; // IndexDto indexDto=null;
//
String querySql = " SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1"; // String querySql = " SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
//
querySql = String.format(querySql, gatewayId, value,daty,daty); // querySql = String.format(querySql, gatewayId, value,daty,daty);
List<IndexDto> queryList = influxDButils.getListData(querySql,IndexDto.class); // List<IndexDto> queryList = influxDButils.getListData(querySql,IndexDto.class);
return queryList; // return queryList;
} // }
public List<IndexDto> getlastgf(String gatewayId, String value,String daty){ // public List<IndexDto> getlastgf(String gatewayId, String value,String daty){
IndexDto indexDto=null; // IndexDto indexDto=null;
String querySql = " SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and equipmentSpecificName =~/.*逆变器.*/ and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1"; // String querySql = " SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and equipmentSpecificName =~/.*逆变器.*/ and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
//
querySql = String.format(querySql, gatewayId, value,daty,daty); // querySql = String.format(querySql, gatewayId, value,daty,daty);
List<IndexDto> queryList = influxDButils.getListData(querySql,IndexDto.class); // List<IndexDto> queryList = influxDButils.getListData(querySql,IndexDto.class);
queryList.forEach(item -> { // queryList.forEach(item -> {
item.setValue(String.valueOf(Double.parseDouble(item.getValue()) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay)); // item.setValue(String.valueOf(Double.parseDouble(item.getValue()) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
item.setValueLabel(String.valueOf(Double.parseDouble(item.getValueLabel()) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay)); // item.setValueLabel(String.valueOf(Double.parseDouble(item.getValueLabel()) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
}); // });
return queryList; // return queryList;
} // }
//更新es 数据 //更新es 数据
//@Async("jxiopAsyncExecutor") //@Async("jxiopAsyncExecutor")
......
...@@ -4,13 +4,8 @@ import com.google.common.collect.Lists; ...@@ -4,13 +4,8 @@ import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.DeviceDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationTaksDto; import com.yeejoin.amos.boot.module.jxiop.api.dto.StationTaksDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.service.IStationDataTask;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.SjglZsjZsbtz; import com.yeejoin.amos.boot.module.jxiop.biz.entity.SjglZsjZsbtz;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.TpriDmpDatabook; import com.yeejoin.amos.boot.module.jxiop.biz.entity.TpriDmpDatabook;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
...@@ -39,8 +34,8 @@ public class StationDataTaskImpl { ...@@ -39,8 +34,8 @@ public class StationDataTaskImpl {
@Value("${station.isok}") @Value("${station.isok}")
private boolean isok; private boolean isok;
@Autowired // @Autowired
InfluxDButils influxDButils; // InfluxDButils influxDButils;
@Autowired @Autowired
MonitorFanIndicatorAsync monitorFanIndicatorAsync; MonitorFanIndicatorAsync monitorFanIndicatorAsync;
...@@ -78,27 +73,27 @@ public class StationDataTaskImpl { ...@@ -78,27 +73,27 @@ public class StationDataTaskImpl {
} }
// @Async("jxiopAsyncExecutor") // @Async("jxiopAsyncExecutor")
public List<IndexDto> getIndexDto(DeviceDto deviceDto) { // public List<IndexDto> getIndexDto(DeviceDto deviceDto) {
String querysql ="SELECT createdTime ,gatewayId,address,valueLabel ,equipmentsIdx FROM iot_data WHERE equipmentSpecificName=~/.*"+deviceDto.getNumberName()+"风机"+".*/ and gatewayId='"+deviceDto.getGateway()+"' ORDER BY time desc LIMIT 600"; // String querysql ="SELECT createdTime ,gatewayId,address,valueLabel ,equipmentsIdx FROM iot_data WHERE equipmentSpecificName=~/.*"+deviceDto.getNumberName()+"风机"+".*/ and gatewayId='"+deviceDto.getGateway()+"' ORDER BY time desc LIMIT 600";
//每个分机的指标数据 // //每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysql,IndexDto.class); // List<IndexDto> list = influxDButils.getListData(querysql,IndexDto.class);
if(list!=null&&list.size()>0){ // if(list!=null&&list.size()>0){
//对数据切片处理 默认创建 // //对数据切片处理 默认创建
if(stationSection>list.size()||!isok){ // if(stationSection>list.size()||!isok){
monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list); // monitorFanIndicatorImpl.UpdateMonitorFanIndicator(list);
}else{ // }else{
//进行分片处理 // //进行分片处理
//
List<List<IndexDto>> listfp4= Lists.partition(list,stationSection); // List<List<IndexDto>> listfp4= Lists.partition(list,stationSection);
for (List<IndexDto> indexDtos : listfp4) { // for (List<IndexDto> indexDtos : listfp4) {
//每个分级信息处理 // //每个分级信息处理
monitorFanIndicatorAsync.UpdateMonitorFanIndicator(indexDtos); // monitorFanIndicatorAsync.UpdateMonitorFanIndicator(indexDtos);
} // }
} // }
} // }
//
return list; // return list;
} // }
......
...@@ -27,17 +27,17 @@ public class StationDataTask { ...@@ -27,17 +27,17 @@ public class StationDataTask {
//定时获取场站指标最新数据 //定时获取场站指标最新数据
// @Scheduled(cron = "${station.task.cron}") // @Scheduled(cron = "${station.task.cron}")
public void getStationDataTask(){ // public void getStationDataTask(){
//获取所有场站信息 // //获取所有场站信息
List<StationTaksDto> list=stationDataTask.getListStationBasic(); // List<StationTaksDto> list=stationDataTask.getListStationBasic();
for (StationTaksDto stationTaksDto : list) { // for (StationTaksDto stationTaksDto : list) {
//获取分机 // //获取分机
List<DeviceDto> listDeviceDto= stationDataTask.getListDevice(stationTaksDto); // List<DeviceDto> listDeviceDto= stationDataTask.getListDevice(stationTaksDto);
if(listDeviceDto!=null&&listDeviceDto.size()>0){ // if(listDeviceDto!=null&&listDeviceDto.size()>0){
for (DeviceDto deviceDto : listDeviceDto) { // for (DeviceDto deviceDto : listDeviceDto) {
List<IndexDto> listIndexDto = stationDataTask.getIndexDto(deviceDto); // List<IndexDto> listIndexDto = stationDataTask.getIndexDto(deviceDto);
} // }
} // }
} // }
} // }
} }
package com.yeejoin.amos.boot.module.jxiop.biz.utils; //package com.yeejoin.amos.boot.module.jxiop.biz.utils;
//
import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import com.squareup.moshi.Json; //import com.squareup.moshi.Json;
import com.yeejoin.amos.component.influxdb.InfluxDbConnection; //import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import com.yeejoin.amos.component.influxdb.InfluxdbUtil; //import com.yeejoin.amos.component.influxdb.InfluxdbUtil;
import org.influxdb.dto.QueryResult; //import org.influxdb.dto.QueryResult;
import org.springframework.beans.BeanWrapperImpl; //import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; //import org.springframework.util.ObjectUtils;
//
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.Date; //import java.util.Date;
import java.util.List; //import java.util.List;
import java.util.Map; //import java.util.Map;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
//
@Component //@Component
public class InfluxDButils { //public class InfluxDButils {
@Autowired // @Autowired
InfluxDbConnection influxDbConnection; // InfluxDbConnection influxDbConnection;
@Autowired // @Autowired
InfluxdbUtil influxdbUtil; // InfluxdbUtil influxdbUtil;
public <T> List<T> getListData(String sql, Class<T> clazz) { // public <T> List<T> getListData(String sql, Class<T> clazz) {
List<T> list = new ArrayList<>(); // List<T> list = new ArrayList<>();
try { // try {
QueryResult query = influxDbConnection.query(sql); // QueryResult query = influxDbConnection.query(sql);
List<QueryResult.Result> queryResults = query.getResults(); // List<QueryResult.Result> queryResults = query.getResults();
for (QueryResult.Result result : queryResults) { // for (QueryResult.Result result : queryResults) {
List<QueryResult.Series> series = result.getSeries(); // List<QueryResult.Series> series = result.getSeries();
if (series == null) { // if (series == null) {
continue; // continue;
} // }
for (QueryResult.Series serie : series) { // for (QueryResult.Series serie : series) {
List<List<Object>> values = serie.getValues(); // List<List<Object>> values = serie.getValues();
List<String> columns = serie.getColumns(); // List<String> columns = serie.getColumns();
for (int i = 0; i < values.size(); ++i) { // for (int i = 0; i < values.size(); ++i) {
T object = clazz.newInstance(); // T object = clazz.newInstance();
BeanWrapperImpl bean = new BeanWrapperImpl(object); // BeanWrapperImpl bean = new BeanWrapperImpl(object);
for (int j = 0; j < columns.size(); ++j) { // for (int j = 0; j < columns.size(); ++j) {
String k = columns.get(j); // String k = columns.get(j);
Object v = values.get(i).get(j); // Object v = values.get(i).get(j);
if ("time".equals(k)) { // if ("time".equals(k)) {
continue; // continue;
} else { // } else {
bean.setPropertyValue(k, v); // bean.setPropertyValue(k, v);
} // }
} // }
list.add(object); // list.add(object);
} // }
} // }
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return list; // return list;
} // }
//
public <T> List<T> getListData1(String sql, Class<T> clazz) { // public <T> List<T> getListData1(String sql, Class<T> clazz) {
List<T> list = new ArrayList<>(); // List<T> list = new ArrayList<>();
try { // try {
List<Map<String,Object>> mapList = influxdbUtil.query(sql); // List<Map<String,Object>> mapList = influxdbUtil.query(sql);
list=mapList.stream().map(stringObjectMap -> JSONObject.parseObject(JSON.toJSONString(stringObjectMap),clazz)).collect(Collectors.toList()); // list=mapList.stream().map(stringObjectMap -> JSONObject.parseObject(JSON.toJSONString(stringObjectMap),clazz)).collect(Collectors.toList());
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return list; // return list;
} // }
//
public <T> List<T> getListDataAll(String sql, Class<T> clazz) { // public <T> List<T> getListDataAll(String sql, Class<T> clazz) {
List<T> list = new ArrayList<>(); // List<T> list = new ArrayList<>();
try { // try {
QueryResult query = influxDbConnection.query(sql); // QueryResult query = influxDbConnection.query(sql);
List<QueryResult.Result> queryResults = query.getResults(); // List<QueryResult.Result> queryResults = query.getResults();
for (QueryResult.Result result : queryResults) { // for (QueryResult.Result result : queryResults) {
List<QueryResult.Series> series = result.getSeries(); // List<QueryResult.Series> series = result.getSeries();
if (series == null) { // if (series == null) {
continue; // continue;
} // }
for (QueryResult.Series serie : series) { // for (QueryResult.Series serie : series) {
List<List<Object>> values = serie.getValues(); // List<List<Object>> values = serie.getValues();
List<String> columns = serie.getColumns(); // List<String> columns = serie.getColumns();
for (int i = 0; i < values.size(); ++i) { // for (int i = 0; i < values.size(); ++i) {
T object = clazz.newInstance(); // T object = clazz.newInstance();
BeanWrapperImpl bean = new BeanWrapperImpl(object); // BeanWrapperImpl bean = new BeanWrapperImpl(object);
for (int j = 0; j < columns.size(); ++j) { // for (int j = 0; j < columns.size(); ++j) {
String k = columns.get(j); // String k = columns.get(j);
Object v = values.get(i).get(j); // Object v = values.get(i).get(j);
//
bean.setPropertyValue(k, v); // bean.setPropertyValue(k, v);
//
} // }
list.add(object); // list.add(object);
} // }
} // }
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return list; // return list;
} // }
} //}
...@@ -91,14 +91,14 @@ emqx.max-inflight=1000 ...@@ -91,14 +91,14 @@ emqx.max-inflight=1000
#spring.influx.bufferLimit=20000 #spring.influx.bufferLimit=20000
spring.influx.url=http://139.9.173.44:18086 #spring.influx.url=http://139.9.173.44:18086
spring.influx.password=Yeejoin@2020 #spring.influx.password=Yeejoin@2020
spring.influx.user=root #spring.influx.user=root
spring.influx.database=iot_platform #spring.influx.database=iot_platform
spring.influx.retention_policy=default #spring.influx.retention_policy=default
spring.influx.retention_policy_time=30d #spring.influx.retention_policy_time=30d
spring.influx.actions=10000 #spring.influx.actions=10000
spring.influx.bufferLimit=20000 #spring.influx.bufferLimit=20000
knife4j.production=false knife4j.production=false
knife4j.enable=true knife4j.enable=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment